#!/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 1272.0 1548.0 25.549733333333332 56.38473333333334 -gcp 21930.0 1545.0 26.743133333333333 56.423116666666665 -gcp 22104.0 16293.0 26.789983333333332 55.94805 -gcp 1365.0 16557.0 25.6084 55.9133 1915_3verst_ru_126k/10-5.jpg 10-5.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "1328.625 9056.625\n1272.0 1548.0\n11604.0 1530.0\n21930.0 1545.0\n22000.5 8923.5\n22104.0 16293.0\n11721.0 16454.25\n1365.0 16557.0" | \ gdaltransform -tps -output_xy 10-5.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ 10-5.vrt 10-5.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES 10-5.cut.vrt 10-5.xyz