#!/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 26.53472673330256 56.85146289036533 -gcp 14340.0 0.0 26.867940386779065 56.85146262726438 -gcp 14340.0 16389.0 26.86701170640218 56.64362321005552 -gcp 0.0 16389.0 26.535252538892312 56.64352669649571 218-Barkava_1925.jpg 218-Barkava_1925.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e \"7186.125 1416.7452109938922\n1801.5 1426.1239589117158\n1789.875 14564.624791782344\n7189.875 14561.997084952804\n12593.625 14569.876041088282\n12592.3125 8008.693746529705\n12567.5625 1424.8123958911715\" | \ gdaltransform -tps -output_xy 218-Barkava_1925.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}'))))" \ 218-Barkava_1925.vrt 218-Barkava_1925.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES 218-Barkava_1925.cut.vrt 218-Barkava_1925.xyz