#!/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 27.783309188530257 57.0209548521339 -gcp 15048.0 0.0 28.13577642088762 57.02007382550602 -gcp 15048.0 16581.0 28.133201952087244 56.81003868949408 -gcp 0.0 16581.0 27.78330640886898 56.80993421282691 276-Gavri_1922.jpg 276-Gavri_1922.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e \"1842.9375 1629.3735424764022\n1850.0625 8184.188020544141\n1854.0 14737.12562465297\n12599.25 14737.118961687951\n12573.75 8188.876041088284\n12600.375 8155.125624652971\n12622.875 8120.991671293726\n12622.875 8084.9787617990005\n12608.625 8059.470433092726\n12586.875 8038.094600222099\n12587.25 7998.756246529705\n13581.375 8001.375312326485\n13541.0625 1580.6247917823432\" | \ gdaltransform -tps -output_xy 276-Gavri_1922.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}'))))" \ 276-Gavri_1922.vrt 276-Gavri_1922.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES 276-Gavri_1922.cut.vrt 276-Gavri_1922.xyz