#!/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 1464.0 1572.0 24.295066666666667 56.80938333333334 -gcp 21972.0 1680.0 25.490083333333335 56.85845 -gcp 21972.0 16281.0 25.549733333333332 56.38473333333334 -gcp 1539.0 16428.0 24.373166666666666 56.33838333333333 1915_3verst_ru_126k/9-4.jpg 9-4.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "1499.25 9000.0\n1464.0 1572.0\n11722.5 1607.9900055524708\n21972.0 1680.0\n21967.5 8981.250416435314\n21972.0 16281.0\n11752.5 16369.508328706273\n1539.0 16428.0" | \ gdaltransform -tps -output_xy 9-4.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ 9-4.vrt 9-4.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES 9-4.cut.vrt 9-4.xyz