#!/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 2283.0 2064.0 26.607166666666668 57.84356666666667 -gcp 22500.0 1980.0 27.84665 57.871916666666664 -gcp 22482.0 16809.0 27.87815 57.39706666666667 -gcp 2313.0 16674.0 26.647333333333332 57.37153333333333 1915_3verst_ru_126k/7-6.jpg 7-6.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "2299.5 9371.25124930594\n2283.0 2064.0\n12390.0 2025.001665741255\n22500.0 1980.0\n22471.5 9395.250416435314\n22482.0 16809.0\n12397.5 16703.979178234316\n2313.0 16674.0" | \ gdaltransform -tps -output_xy 7-6.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ 7-6.vrt 7-6.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES 7-6.cut.vrt 7-6.xyz