#!/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 1356.0 1779.0 20.46375 57.5319 -gcp 21774.0 1671.0 21.6816 57.61686666666667 -gcp 21990.0 16314.0 21.789666666666665 57.15136666666667 -gcp 1554.0 16479.0 20.58735 57.066583333333334 1915_3verst_ru_126k/7-1.jpg 7-1.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "1467.75 9132.752082176568\n1356.0 1779.0\n11565.0 1697.9850083287063\n21774.0 1671.0\n21883.5 8999.253747917825\n21990.0 16314.0\n11769.75 16404.754580788453\n1554.0 16479.0" | \ gdaltransform -tps -output_xy 7-1.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ 7-1.vrt 7-1.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES 7-1.cut.vrt 7-1.xyz