#!/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.53066136611121 57.68475265880319 -gcp 14340.0 0.0 26.871435965479996 57.683968241218025 -gcp 14340.0 16344.0 26.86757217278228 57.47639930545787 -gcp 0.0 16344.0 26.52848673073089 57.4775252491502 213-Ape_1924.jpg 213-Ape_1924.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e \"7201.875 1377.7433370349806\n1945.5 1414.8743753470294\n1980.0 7991.252082176569\n2027.25 14560.123958911718\n12597.0 14494.499167129372\n12477.0 1365.0\" | \ gdaltransform -tps -output_xy 213-Ape_1924.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}'))))" \ 213-Ape_1924.vrt 213-Ape_1924.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES 213-Ape_1924.cut.vrt 213-Ape_1924.xyz