#!/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 26.02235 56.70028333 -gcp 21600.0 0.0 26.04521667 56.61671667 -gcp 21600.0 21849.0 25.89378333 56.60248333 -gcp 0.0 21849.0 25.8659 56.68648333 GX10511/GX_10511_SK_frame_59.jpg GX_10511_SK_frame_59.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "1056.0 2448.0\n1140.0 19296.0\n21048.0 19608.0\n20988.0 1968.0" | \ gdaltransform -tps -output_xy GX_10511_SK_frame_59.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_10511_SK_frame_59.vrt GX_10511_SK_frame_59.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_10511_SK_frame_59.cut.vrt GX_10511_SK_frame_59.xyz