#!/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.03712559 57.75771625 -gcp 21627.0 0.0 26.03060155 57.78927954 -gcp 21627.0 21252.0 26.0898891 57.79297372 -gcp 0.0 21252.0 26.09613419 57.76073831 GX856/GX_856_SK_frame_4.jpg GX_856_SK_frame_4.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "816.0 1799.9199555308503\n20928.0 2015.8799332962758\n21072.0 19007.85325180656\n696.0 18696.506948304614" | \ gdaltransform -tps -output_xy GX_856_SK_frame_4.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_856_SK_frame_4.vrt GX_856_SK_frame_4.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_856_SK_frame_4.cut.vrt GX_856_SK_frame_4.xyz