#!/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 24.18418586 56.98442198 -gcp 11412.0 0.0 24.2276752 56.97204155 -gcp 11412.0 11904.0 24.20391619 56.94652491 -gcp 0.0 11904.0 24.15848494 56.95868284 GX224/GX_224_SD_frame_83.jpg GX_224_SD_frame_83.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "228.0 1895.9465181058495\n936.0 1644.1337047353759\n1128.0 815.9465181058495\n10728.0 743.2245125348186\n10728.0 11112.106963788301\n228.0 11184.026740947076" | \ gdaltransform -tps -output_xy GX_224_SD_frame_83.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_224_SD_frame_83.vrt GX_224_SD_frame_83.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_224_SD_frame_83.cut.vrt GX_224_SD_frame_83.xyz