#!/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 420.0 840.0 27.333333333333332 56.416666666666664 -gcp 12558.0 870.0 27.5 56.416666666666664 -gcp 12534.0 11826.0 27.5 56.333333333333336 -gcp 363.0 11790.0 27.333333333333332 56.333333333333336 95-f.jpg 95-f.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e \"420.0 840.0\n12558.0 870.0\n12534.0 11826.0\n363.0 11790.0\" | \ gdaltransform -tps -output_xy 95-f.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}'))))" \ 95-f.vrt 95-f.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES 95-f.cut.vrt 95-f.xyz