#!/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 1107.8160645627281 1485.9827025021611 25.28757423 57.34005745 -gcp 9721.779227222294 1755.912960741185 25.31595469 57.32243766 -gcp 11111.695084400237 10179.36627611707 25.28955638 57.3038271 -gcp 1280.5758561851926 9779.52310560474 25.25716603 57.32414066 GX18586/GX_18586_SK_frame_13.jpg GX_18586_SK_frame_13.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "552.0 1511.9753213367603\n11616.0 1224.1604113110538\n11544.0 10871.876606683803\n408.0 10824.160411311055" | \ gdaltransform -tps -output_xy GX_18586_SK_frame_13.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_18586_SK_frame_13.vrt GX_18586_SK_frame_13.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_18586_SK_frame_13.cut.vrt GX_18586_SK_frame_13.xyz