#!/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.456462980105 56.597337087731 -gcp 10671.0 0.0 21.45579457283 56.569934075059 -gcp 10671.0 12486.0 21.398009061813 56.570377376232 -gcp 0.0 12486.0 21.398749351501 56.597692431215 Aizpute-1988-991/Aizpute-1988-991-62.jpg Aizpute-1988-991-62.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "618.0 1266.0\n10498.5 1003.5\n10648.5 10938.0\n877.5 11178.0" | \ gdaltransform -tps -output_xy Aizpute-1988-991-62.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ Aizpute-1988-991-62.vrt Aizpute-1988-991-62.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES Aizpute-1988-991-62.cut.vrt Aizpute-1988-991-62.xyz