#!/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 1386.0 1728.0 21.898233333333334 56.677033333333334 -gcp 21945.0 1650.0 23.093783333333334 56.74915 -gcp 22116.0 16353.0 23.18235 56.2773 -gcp 1545.0 16638.0 22.0042 56.20791666666667 1915_3verst_ru_126k/9-2.jpg 9-2.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "1459.5 9183.0\n1386.0 1728.0\n11664.75 1702.5074958356468\n21945.0 1650.0\n22036.5 9009.004164353137\n22116.0 16353.0\n11831.25 16466.984175458078\n1545.0 16638.0" | \ gdaltransform -tps -output_xy 9-2.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ 9-2.vrt 9-2.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES 9-2.cut.vrt 9-2.xyz