#!/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 933.0 930.0 24 57 -gcp 11643.0 894.0 25.5 57 -gcp 11865.0 14007.0 25.5 56 -gcp 870.0 14088.0 24 56 43_Riga_1932.jpg 43_Riga_1932.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e \"930.0 933.0\n869.625 14089.123958911718\n11866.125 14010.375208217656\n11647.125 893.6231260410882\" | \ gdaltransform -tps -output_xy 43_Riga_1932.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}'))))" \ 43_Riga_1932.vrt 43_Riga_1932.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES 43_Riga_1932.cut.vrt 43_Riga_1932.xyz