#!/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 23.26080322 57.1869485 -gcp 16929.0 0.0 23.2013011 57.17300401 -gcp 16929.0 16356.0 23.17456484 57.20489762 -gcp 0.0 16356.0 23.23711395 57.21898111 GX18588/GX_18588_SK_frame_39.jpg GX_18588_SK_frame_39.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "1344.0 2202.0\n2508.0 2160.0\n2538.0 954.0\n6678.0 888.0\n7920.0 1074.0\n8880.0 1044.0\n9930.0 870.0\n15867.0 738.0\n15954.0 7599.0\n15963.0 8724.0\n16146.0 15156.0\n4632.0 15378.0\n3666.0 15084.0\n2424.0 14346.0\n1506.0 14280.0" | \ gdaltransform -tps -output_xy GX_18588_SK_frame_39.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_18588_SK_frame_39.vrt GX_18588_SK_frame_39.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_18588_SK_frame_39.cut.vrt GX_18588_SK_frame_39.xyz