#!/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 2256.0 2280.0 21.56985 58.0923 -gcp 22557.0 2169.0 22.820666666666668 58.16635 -gcp 22572.0 16995.0 22.913183333333333 57.69295 -gcp 2220.0 16881.0 21.6816 57.61686666666667 1915_3verst_ru_126k/6-2.jpg 6-2.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "2244.75 9589.504997223765\n2256.0 2280.0\n12402.75 2233.504997223765\n22557.0 2169.0\n22561.5 9585.001665741254\n22572.0 16995.0\n12405.0 16934.998334258744\n2220.0 16881.0" | \ gdaltransform -tps -output_xy 6-2.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ 6-2.vrt 6-2.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES 6-2.cut.vrt 6-2.xyz