#!/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 1485.0 1566.0 22.820666666666668 58.16635 -gcp 22212.0 1527.0 24.053533333333334 58.22678333333333 -gcp 22188.0 16422.0 24.1349 57.754 -gcp 1338.0 16281.0 22.913183333333333 57.69295 1915_3verst_ru_126k/6-3.jpg 6-3.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "1485.0 1566.0\n11850.0 1564.5099944475292\n22212.0 1527.0\n22185.75 8988.007495835647\n22188.0 16422.0\n11763.0 16359.75458078845\n1338.0 16281.0" | \ gdaltransform -tps -output_xy 6-3.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ 6-3.vrt 6-3.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES 6-3.cut.vrt 6-3.xyz