#!/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 3773.9930362754417 5101.618783494206 24.55536604 57.27089948 -gcp 18981.068951494555 2900.9963151778875 24.54075336 57.33285513 -gcp 20390.992179948065 16086.708639856271 24.63846087 57.3373275 -gcp 4445.6597409035785 19236.198139985532 24.65980053 57.27299339 GX8464/GX_8464_SK_frame_289.jpg GX_8464_SK_frame_289.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "720.0 2694.0\n20928.0 2448.0534818941505\n20928.0 19824.16044568245\n624.0 19631.8930362117" | \ gdaltransform -tps -output_xy GX_8464_SK_frame_289.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_8464_SK_frame_289.vrt GX_8464_SK_frame_289.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_8464_SK_frame_289.cut.vrt GX_8464_SK_frame_289.xyz