#!/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 1257.0 1557.0 21.6816 57.61686666666667 -gcp 21882.0 1488.0 22.913183333333333 57.69295 -gcp 21867.0 16359.0 23.004 57.22128333333333 -gcp 1251.0 16245.0 21.789666666666665 57.15136666666667 1915_3verst_ru_126k/7-2.jpg 7-2.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "1247.25 8905.502498611882\n1257.0 1557.0\n11569.5 1513.4950027762354\n21882.0 1488.0\n21882.0 8925.000832870628\n21867.0 16359.0\n11560.5 16276.485841199334\n1251.0 16245.0" | \ gdaltransform -tps -output_xy 7-2.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ 7-2.vrt 7-2.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES 7-2.cut.vrt 7-2.xyz