#!/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 2871.3374852449037 5555.25014465945 26.63420141 57.16978459 -gcp 18316.729516037005 4944.887318278239 26.64885163 57.10930883 -gcp 18837.155760459795 19404.393711283887 26.54653072 57.1016595 -gcp 1659.5674755378413 17432.70264278908 26.54728711 57.17029348 GX10514/GX_10514_SK_frame_464.jpg GX_10514_SK_frame_464.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "528.0 2934.0\n20640.0 2928.50807799443\n20544.0 20255.91977715878\n432.0 19968.240668523675" | \ gdaltransform -tps -output_xy GX_10514_SK_frame_464.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_10514_SK_frame_464.vrt GX_10514_SK_frame_464.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_10514_SK_frame_464.cut.vrt GX_10514_SK_frame_464.xyz