#!/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 27.14554596 57.25387473 -gcp 21600.0 0.0 27.15694539 57.33824214 -gcp 21600.0 23403.0 27.32372877 57.33195559 -gcp 0.0 23403.0 27.31627263 57.24927477 GX8464/GX_8464_SK_frame_244.jpg GX_8464_SK_frame_244.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "651.0 2280.0\n551.9795744680855 19344.0\n21000.15659574468 19584.0\n21216.061276595745 1896.0" | \ gdaltransform -tps -output_xy GX_8464_SK_frame_244.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_8464_SK_frame_244.vrt GX_8464_SK_frame_244.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_8464_SK_frame_244.cut.vrt GX_8464_SK_frame_244.xyz