#!/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 1738.0415129031298 6581.531081083625 25.80924511 57.26544078 -gcp 20375.269117868855 3474.802624717191 25.78814149 57.33750124 -gcp 20436.364386099714 17298.923551498807 25.88870287 57.33707269 -gcp 3925.10497121598 20995.67787325246 25.91363668 57.2727092 GX8464/GX_8464_SK_frame_268.jpg GX_8464_SK_frame_268.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "432.0 2387.897435897436\n20952.0 2377.194570135747\n20832.0 19630.105580693817\n480.0 19221.900452488688" | \ gdaltransform -tps -output_xy GX_8464_SK_frame_268.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_8464_SK_frame_268.vrt GX_8464_SK_frame_268.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_8464_SK_frame_268.cut.vrt GX_8464_SK_frame_268.xyz