#!/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.444697699827 56.57666613585 -gcp 12114.0 0.0 21.439612334759 56.545642876562 -gcp 12114.0 13947.0 21.374881083222 56.549148267518 -gcp 0.0 13947.0 21.38045461033 56.579861211513 Aizpute-1988-991/Aizpute-1988-991-50.jpg Aizpute-1988-991-50.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "490.5 2697.0\n10266.0 1374.0\n11597.25 11192.25\n1779.0 12492.0" | \ gdaltransform -tps -output_xy Aizpute-1988-991-50.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ Aizpute-1988-991-50.vrt Aizpute-1988-991-50.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES Aizpute-1988-991-50.cut.vrt Aizpute-1988-991-50.xyz