#!/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.287321888848 56.554965082502 -gcp 10512.0 0.0 21.286583106912 56.527958208974 -gcp 10512.0 12501.0 21.228848987371 56.528255866295 -gcp 0.0 12501.0 21.22908887843 56.555274572756 Aizpute-1988-991/Aizpute-1988-991-41.jpg Aizpute-1988-991-41.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "12.0 6051.0\n3.0 1218.0\n9715.5 897.0\n10035.0 10819.5\n165.0 11128.5" | \ gdaltransform -tps -output_xy Aizpute-1988-991-41.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ Aizpute-1988-991-41.vrt Aizpute-1988-991-41.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES Aizpute-1988-991-41.cut.vrt Aizpute-1988-991-41.xyz