#!/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 1623.0 1614.0 24.053533333333334 58.22678333333333 -gcp 22359.0 1461.0 25.306583333333332 58.27615 -gcp 22413.0 16374.0 25.368466666666666 57.80485 -gcp 1683.0 16335.0 24.1349 57.754 1915_3verst_ru_126k/6-4.jpg 6-4.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "1654.5 8978.252082176568\n1623.0 1614.0\n11991.0 1548.0058300943922\n22359.0 1461.0\n22413.0 16374.0\n12049.5 16352.999167129372\n1683.0 16335.0" | \ gdaltransform -tps -output_xy 6-4.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ 6-4.vrt 6-4.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES 6-4.cut.vrt 6-4.xyz