#!/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 25.17542839 57.2576946 -gcp 21627.0 0.0 25.18448478 57.34485454 -gcp 21627.0 21768.0 25.34417278 57.34010719 -gcp 0.0 21768.0 25.3390646 57.2555591 GX8464/GX_8464_SK_frame_278.jpg GX_8464_SK_frame_278.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "816.0 1799.906406685237\n20688.0 1487.8128133704731\n20784.0 11612.122562674094\n816.0 11708.336490250696" | \ gdaltransform -tps -output_xy GX_8464_SK_frame_278.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_8464_SK_frame_278.vrt GX_8464_SK_frame_278.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_8464_SK_frame_278.cut.vrt GX_8464_SK_frame_278.xyz