#!/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 1947.0 2307.0 21.5 56.666666666666664 -gcp 23445.0 2478.0 22 56.666666666666664 -gcp 23391.0 28350.0 22 56.333333333333336 -gcp 1614.0 28191.0 21.5 56.333333333333336 O-34-128_y.jpg O-34-128_y.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "1947.0 2307.0\n23445.0 2478.0\n23391.0 28350.0\n1614.0 28191.0" | \ gdaltransform -tps -output_xy O-34-128_y.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ O-34-128_y.vrt O-34-128_y.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES O-34-128_y.cut.vrt O-34-128_y.xyz