#!/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 2055.0 1794.0 20.8318 56.12565 -gcp 22449.0 1905.0 22.0042 56.20791666666667 -gcp 22491.0 16551.0 22.1088 55.73328333333333 -gcp 2031.0 16632.0 20.9438 55.65645 1915_3verst_ru_126k/10-1.jpg 10-1.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "2051.25 9216.0\n2055.0 1794.0\n12255.0 1854.0\n22449.0 1905.0\n22462.5 9233.25\n22491.0 16551.0\n12258.75 16599.0\n2031.0 16632.0" | \ gdaltransform -tps -output_xy 10-1.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ 10-1.vrt 10-1.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES 10-1.cut.vrt 10-1.xyz