#!/bin/bash GDAL_TILE_PROCESSES=16 GDAL_TILE_ZOOMS=8-14 GDAL_SAMPLING_WARP=cubic GDAL_SAMPLING_TILE=antialias # Create virtual dataset with coordinates gdal_translate -of VRT -a_srs EPSG:4326 -outsize 300% 300% -gcp 0.0 0.0 25.20134926 57.81794947 -gcp 14118.0 0.0 25.36219597 57.82400612 -gcp 14118.0 13953.0 25.39501915 57.72182045 -gcp 0.0 13953.0 25.18830299 57.72454855 GX954/GX_954_SK_frame_54.jpg GX_954_SK_frame_54.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "456.0 1179.0\n13848.0 984.0533037201556\n13752.0 12575.920044419767\n480.0 12528.053303720155" | \ gdaltransform -tps -output_xy GX_954_SK_frame_54.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_954_SK_frame_54.vrt GX_954_SK_frame_54.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_954_SK_frame_54.cut.vrt GX_954_SK_frame_54.xyz