#!/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 1305.0 1518.0 25.306583333333332 58.27615 -gcp 22083.0 1413.0 26.553616666666667 58.315983333333335 -gcp 22113.0 16314.0 26.607166666666668 57.84356666666667 -gcp 1293.0 16227.0 25.368466666666666 57.80485 1915_3verst_ru_126k/6-5.jpg 6-5.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "1305.75 8876.252082176568\n1305.0 1518.0\n11689.5 1476.7562465297058\n22083.0 1413.0\n22089.75 8865.000832870628\n22113.0 16314.0\n11702.625 16268.999167129372\n1293.0 16227.0" | \ gdaltransform -tps -output_xy 6-5.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ 6-5.vrt 6-5.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES 6-5.cut.vrt 6-5.xyz