#!/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 1422.0673658382418 5915.016371564132 25.27673542 57.26548258 -gcp 18264.961609326376 5044.671397834174 25.27332902 57.33230687 -gcp 19277.1873627026 18541.507039670414 25.37337542 57.33422367 -gcp 1904.5480272554883 17226.610935501674 25.35996437 57.26627016 GX8464/GX_8464_SK_frame_277.jpg GX_8464_SK_frame_277.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "912.0 2454.0\n20592.0 2447.572144846797\n20928.0 19488.481337047357\n624.0 19104.267409470755" | \ gdaltransform -tps -output_xy GX_8464_SK_frame_277.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_8464_SK_frame_277.vrt GX_8464_SK_frame_277.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_8464_SK_frame_277.cut.vrt GX_8464_SK_frame_277.xyz