#!/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 4053.3069284030817 4304.131490869965 25.32727361 57.27433908 -gcp 18743.035725610982 2734.300770833811 25.31793952 57.33239381 -gcp 17305.313775394567 19197.94775022978 25.43889642 57.32566982 -gcp 3916.9330281758353 19570.356277893145 25.44008732 57.27268599 GX8464/GX_8464_SK_frame_276.jpg GX_8464_SK_frame_276.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_276.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_8464_SK_frame_276.vrt GX_8464_SK_frame_276.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_8464_SK_frame_276.cut.vrt GX_8464_SK_frame_276.xyz