#!/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 2545.541852309988 4340.191390690125 24.96752501 57.26705882 -gcp 19844.81740101034 3695.454849359774 24.96281505 57.33605938 -gcp 18331.854717770548 16005.324080354989 25.05429983 57.33021642 -gcp 2044.5306231264115 17929.100504449718 25.06951869 57.26506053 GX8464/GX_8464_SK_frame_282.jpg GX_8464_SK_frame_282.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "816.0 2591.9732590529247\n576.0 19296.187186629526\n20784.0 19680.08022284122\n21024.0 2352.641782729805" | \ gdaltransform -tps -output_xy GX_8464_SK_frame_282.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_8464_SK_frame_282.vrt GX_8464_SK_frame_282.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_8464_SK_frame_282.cut.vrt GX_8464_SK_frame_282.xyz