#!/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 1395.0 1638.0 29.068483333333333 58.3633 -gcp 22110.0 1596.0 30.33265 58.370583333333336 -gcp 22029.0 16473.0 30.332516666666667 57.8954 -gcp 1329.0 16320.0 29.086766666666666 57.8924 1915_3verst_ru_126k/6-8.jpg 6-8.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "1379.25 8987.25458078845\n1395.0 1638.0\n11737.5 1600.4908384230985\n22110.0 1596.0\n22062.0 9048.006662965021\n22029.0 16473.0\n11680.5 16405.504997223765\n1329.0 16320.0" | \ gdaltransform -tps -output_xy 6-8.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ 6-8.vrt 6-8.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES 6-8.cut.vrt 6-8.xyz