#!/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 26.76918274 56.01866203 -gcp 42618.0 0.0 26.73014357 56.03473828 -gcp 42618.0 43323.0 26.76001433 56.05928189 -gcp 0.0 43323.0 26.80069829 56.04067622 GX737/GX_737_SD_frame_105.jpg GX_737_SD_frame_105.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "1632.0 3935.4130072262365\n1560.0 38579.99332962757\n41952.0 39071.6798221234\n41328.0 6134.261256253475\n33888.0 5568.293496386881\n31104.0 3791.679822123401" | \ gdaltransform -tps -output_xy GX_737_SD_frame_105.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_737_SD_frame_105.vrt GX_737_SD_frame_105.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_737_SD_frame_105.cut.vrt GX_737_SD_frame_105.xyz