#!/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 1383.0 1539.0 31.583716666666668 58.364133333333335 -gcp 22092.0 1449.0 32.841433333333335 58.34721666666667 -gcp 22161.0 16428.0 32.810833333333335 57.87355 -gcp 1344.0 16302.0 31.56735 57.8898 1915_3verst_ru_126k/6-10.jpg 6-10.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "1380.75 8934.757912270961\n1383.0 1539.0\n11737.5 1518.013325930039\n22092.0 1449.0\n22113.0 8940.75124930594\n22161.0 16428.0\n11751.0 16377.006662965021\n1344.0 16302.0" | \ gdaltransform -tps -output_xy 6-10.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ 6-10.vrt 6-10.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES 6-10.cut.vrt 6-10.xyz