#!/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.507571935654 56.57637029831 -gcp 10506.0 0.0 21.508103013039 56.549601656501 -gcp 10506.0 12444.0 21.450460271375 56.549091435301 -gcp 0.0 12444.0 21.449990272522 56.576062991899 Aizpute-1988-991/Aizpute-1988-991-53.jpg Aizpute-1988-991-53.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "12.0 1092.0\n9873.0 853.5\n10111.5 10764.0\n208.5 10977.0" | \ gdaltransform -tps -output_xy Aizpute-1988-991-53.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ Aizpute-1988-991-53.vrt Aizpute-1988-991-53.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES Aizpute-1988-991-53.cut.vrt Aizpute-1988-991-53.xyz