#!/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 1299.0 1614.0 20.58735 57.066583333333334 -gcp 21921.0 1548.0 21.789666666666665 57.15136666666667 -gcp 21906.0 16377.0 21.898233333333334 56.677033333333334 -gcp 1275.0 16257.0 20.710266666666666 56.59578333333333 1915_3verst_ru_126k/8-1.jpg 8-1.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "1288.5 8937.75124930594\n1299.0 1614.0\n11607.75 1584.001665741255\n21921.0 1548.0\n21909.375 8965.876873958912\n21906.0 16377.0\n11593.5 16310.996668517491\n1275.0 16257.0" | \ gdaltransform -tps -output_xy 8-1.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ 8-1.vrt 8-1.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES 8-1.cut.vrt 8-1.xyz