#!/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 2380.317696173377 4039.059952198215 24.42513943 57.26554969 -gcp 18266.083768252174 5705.584995802468 24.44137216 57.32971773 -gcp 20446.1479466195 19636.075407553424 24.54425097 57.33671079 -gcp 1732.2084218892683 19794.065824828238 24.54197645 57.2611529 GX8464/GX_8464_SK_frame_291.jpg GX_8464_SK_frame_291.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "720.0 2975.8662952646237\n20880.0 2928.0534818941505\n20784.0 20015.518662952643\n480.0 20159.973259052927" | \ gdaltransform -tps -output_xy GX_8464_SK_frame_291.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_8464_SK_frame_291.vrt GX_8464_SK_frame_291.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_8464_SK_frame_291.cut.vrt GX_8464_SK_frame_291.xyz