#!/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 1251.0 1602.0 21.789666666666665 57.15136666666667 -gcp 21987.0 1632.0 23.004 57.22128333333333 -gcp 22041.0 16398.0 23.093783333333334 56.74915 -gcp 1356.0 16563.0 21.898233333333334 56.677033333333334 1915_3verst_ru_126k/8-2.jpg 8-2.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "1282.5 9093.005830094391\n1251.0 1602.0\n11619.375 1617.7504164353136\n21987.0 1632.0\n22026.75 9021.753747917825\n22041.0 16398.0\n11698.5 16467.742920599667\n1356.0 16563.0" | \ gdaltransform -tps -output_xy 8-2.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ 8-2.vrt 8-2.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES 8-2.cut.vrt 8-2.xyz