#!/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 1392.0 1674.0 26.69558333333333 56.89803333333333 -gcp 21915.0 1701.0 27.908883333333332 56.924366666666664 -gcp 22032.0 16398.0 27.939783333333335 56.44968333333333 -gcp 1431.0 16584.0 26.743133333333333 56.423116666666665 1915_3verst_ru_126k/9-6.jpg 9-6.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "1416.0 9130.12562465297\n1392.0 1674.0\n11653.5 1696.5049972237648\n21915.0 1701.0\n21978.75 9054.752915047196\n22032.0 16398.0\n11730.75 16498.504164353137\n1431.0 16584.0" | \ gdaltransform -tps -output_xy 9-6.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ 9-6.vrt 9-6.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES 9-6.cut.vrt 9-6.xyz