#!/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 1455.0 1635.0 26.647333333333332 57.37153333333333 -gcp 21840.0 1638.0 27.87815 57.39706666666667 -gcp 21963.0 16215.0 27.908883333333332 56.924366666666664 -gcp 1566.0 16473.0 26.69558333333333 56.89803333333333 1915_3verst_ru_126k/8-6.jpg 8-6.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "1489.5 9066.006662965021\n1455.0 1635.0\n11651.25 1671.019156024431\n21840.0 1638.0\n21903.0 8931.752915047196\n21963.0 16215.0\n11901.0 16324.504164353137\n1566.0 16473.0" | \ gdaltransform -tps -output_xy 8-6.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ 8-6.vrt 8-6.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES 8-6.cut.vrt 8-6.xyz