#!/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.03308634846388 57.18665616406889 -gcp 14340.0 0.0 27.369979241472016 57.18684069014536 -gcp 14340.0 16710.0 27.368868697540304 56.974775912037074 -gcp 0.0 16710.0 27.033940394427155 56.974899833732955 240-Bolvi_1923.jpg 240-Bolvi_1923.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e \"7176.75 1574.998334258745\n1854.0 1572.0\n1832.625 14724.187604108829\n7182.0 14726.62749861188\n12533.625 14720.063645197115\n12504.0 1584.0\" | \ gdaltransform -tps -output_xy 240-Bolvi_1923.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}'))))" \ 240-Bolvi_1923.vrt 240-Bolvi_1923.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES 240-Bolvi_1923.cut.vrt 240-Bolvi_1923.xyz