#!/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 1023.6154297630717 2922.6855884703677 25.0810039 57.26300671 -gcp 17555.404962423883 4621.762074430564 25.09055257 57.32921701 -gcp 19462.97287314205 18872.64323420218 25.19649982 57.33810362 -gcp 2991.9514561208116 18544.62352748903 25.19698262 57.27284841 GX8464/GX_8464_SK_frame_280.jpg GX_8464_SK_frame_280.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "0.0 0.0\n0.0 23400.941688654355\n21598.423242572448 23400.941688654355\n21598.423242572448 0.0" | \ gdaltransform -tps -output_xy GX_8464_SK_frame_280.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_8464_SK_frame_280.vrt GX_8464_SK_frame_280.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_8464_SK_frame_280.cut.vrt GX_8464_SK_frame_280.xyz