#!/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 24.09649372 56.90989262 -gcp 16284.0 0.0 24.06392097 56.93226151 -gcp 16284.0 17775.0 24.10818489 56.95099269 -gcp 0.0 17775.0 24.13951635 56.93035306 GX11706/GX_11706_SD_frame_69.jpg GX_11706_SD_frame_69.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "672.0 3936.0\n2016.0 3828.006685236769\n2208.0 2615.358217270195\n14388.0 2639.9866295264624\n14388.0 3744.2674094707518\n15336.0 3864.401114206128\n15240.0 17064.0\n744.0 16967.95988857939" | \ gdaltransform -tps -output_xy GX_11706_SD_frame_69.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_11706_SD_frame_69.vrt GX_11706_SD_frame_69.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_11706_SD_frame_69.cut.vrt GX_11706_SD_frame_69.xyz