#!/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 1581.0 1578.0 24.215583333333335 57.2808 -gcp 22077.0 1677.0 25.429566666666666 57.33153333333333 -gcp 22089.0 16386.0 25.490083333333335 56.85845 -gcp 1611.0 16470.0 24.295066666666667 56.80938333333334 1915_3verst_ru_126k/8-4.jpg 8-4.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "1612.5 9030.753747917825\n1581.0 1578.0\n11832.0 1613.9925041643532\n22077.0 1677.0\n22080.0 9036.002498611882\n22089.0 16386.0\n11848.875 16437.004997223765\n1611.0 16470.0" | \ gdaltransform -tps -output_xy 8-4.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ 8-4.vrt 8-4.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES 8-4.cut.vrt 8-4.xyz