#!/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 26.40546799 57.39545027 -gcp 10125.0 0.0 26.40834332 57.3117719 -gcp 10125.0 10146.0 26.25562906 57.30848056 -gcp 0.0 10146.0 26.24809742 57.39365823 GX8473/GX_8473_SK_frame_220.jpg GX_8473_SK_frame_220.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "552.0 945.7053918843806\n9900.0 815.6998332406893\n9792.0 9060.053362979434\n360.0 9023.973318510283" | \ gdaltransform -tps -output_xy GX_8473_SK_frame_220.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_8473_SK_frame_220.vrt GX_8473_SK_frame_220.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_8473_SK_frame_220.cut.vrt GX_8473_SK_frame_220.xyz