#!/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 1326.0 1602.0 26.553616666666667 58.315983333333335 -gcp 22032.0 1572.0 27.812216666666668 58.346266666666665 -gcp 21984.0 16488.0 27.84665 57.871916666666664 -gcp 1275.0 16281.0 26.607166666666668 57.84356666666667 1915_3verst_ru_126k/6-6.jpg 6-6.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "1298.625 8941.5\n1326.0 1602.0\n11679.75 1583.998334258745\n22032.0 1572.0\n22015.5 9033.752082176568\n21984.0 16488.0\n11629.5 16381.873542476402\n1275.0 16281.0" | \ gdaltransform -tps -output_xy 6-6.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ 6-6.vrt 6-6.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES 6-6.cut.vrt 6-6.xyz