#!/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.80739834 56.65450677 -gcp 21540.0 0.0 24.8160967 56.73928649 -gcp 21540.0 23217.0 24.97551138 56.73552552 -gcp 0.0 23217.0 24.97430684 56.65152999 GX10504/GX_10504_SK_frame_846.jpg GX_10504_SK_frame_846.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "888.0 2688.0\n1080.0 19824.0\n20844.0 19944.0\n20976.0 2400.0" | \ gdaltransform -tps -output_xy GX_10504_SK_frame_846.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_10504_SK_frame_846.vrt GX_10504_SK_frame_846.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_10504_SK_frame_846.cut.vrt GX_10504_SK_frame_846.xyz