#!/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.87736671 56.65496868 -gcp 21540.0 0.0 24.87702756 56.73995373 -gcp 21540.0 23217.0 25.03896953 56.74075454 -gcp 0.0 23217.0 25.04341403 56.65666517 GX10504/GX_10504_SK_frame_845.jpg GX_10504_SK_frame_845.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "732.0 2148.0\n768.0 19296.0\n20904.0 19620.0\n20928.0 1824.0" | \ gdaltransform -tps -output_xy GX_10504_SK_frame_845.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_10504_SK_frame_845.vrt GX_10504_SK_frame_845.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_10504_SK_frame_845.cut.vrt GX_10504_SK_frame_845.xyz