#!/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 441.0 990.0 27.166666666666668 56.5 -gcp 12558.0 1020.0 27.333333333333332 56.5 -gcp 12525.0 11982.0 27.333333333333332 56.416666666666664 -gcp 387.0 11937.0 27.166666666666668 56.416666666666664 95-b.jpg 95-b.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e \"441.0 990.0\n12558.0 1020.0\n12525.0 11982.0\n387.0 11937.0\" | \ gdaltransform -tps -output_xy 95-b.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}'))))" \ 95-b.vrt 95-b.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES 95-b.cut.vrt 95-b.xyz