#!/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 1182.0 819.0 22 57.333333333333336 -gcp 22620.0 951.0 24 57.333333333333336 -gcp 22677.0 14202.0 24 56.666666666666664 -gcp 876.0 14067.0 22 56.666666666666664 lnb/24635487.jpg 24635487.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "1182.0 819.0\n11839.5 961.5425236242356\n22620.0 951.0\n22677.0 14202.0\n11745.0 14223.048360200111\n876.0 14067.0" | \ gdaltransform -tps -output_xy 24635487.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ 24635487.vrt 24635487.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES 24635487.cut.vrt 24635487.xyz