#!/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 0.0 0.0 21.431579589844 56.596906874729 -gcp 10743.0 0.0 21.431483030319 56.569325266313 -gcp 10743.0 12117.0 21.375467777252 56.569425749985 -gcp 0.0 12117.0 21.375339031219 56.596936407223 Aizpute-1988-991/Aizpute-1988-991-63.jpg Aizpute-1988-991-63.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "327.0 804.0\n10203.0 597.0\n10392.0 10530.0\n517.5 10714.5" | \ gdaltransform -tps -output_xy Aizpute-1988-991-63.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ Aizpute-1988-991-63.vrt Aizpute-1988-991-63.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES Aizpute-1988-991-63.cut.vrt Aizpute-1988-991-63.xyz