#!/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 1413.0 1656.0 23.004 57.22128333333333 -gcp 22068.0 1683.0 24.215583333333335 57.2808 -gcp 22119.0 16446.0 24.295066666666667 56.80938333333334 -gcp 1506.0 16569.0 23.093783333333334 56.74915 1915_3verst_ru_126k/8-3.jpg 8-3.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "1455.0 9112.5\n1413.0 1656.0\n11741.25 1665.7479178234314\n22068.0 1683.0\n22071.0 9073.504997223765\n22119.0 16446.0\n11802.0 16508.250416435316\n1506.0 16569.0" | \ gdaltransform -tps -output_xy 8-3.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ 8-3.vrt 8-3.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES 8-3.cut.vrt 8-3.xyz