#!/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 1983.0 1464.0 23.337216666666666 56.5 -gcp 13089.0 1476.0 24.337216666666666 56.5 -gcp 13104.0 11484.0 24.337216666666666 56 -gcp 1953.0 11496.0 23.337216666666666 56 lnb/27352323.jpg 27352323.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "1983.0 1464.0\n13089.0 1476.0\n13104.0 11484.0\n1953.0 11496.0" | \ gdaltransform -tps -output_xy 27352323.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ 27352323.vrt 27352323.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES 27352323.cut.vrt 27352323.xyz