#!/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 1203.0 1659.0 24.1349 57.754 -gcp 21780.0 1365.0 25.368466666666666 57.80485 -gcp 21837.0 16266.0 25.429566666666666 57.33153333333333 -gcp 1251.0 16332.0 24.215583333333335 57.2808 1915_3verst_ru_126k/7-4.jpg 7-4.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "1231.5 8997.75124930594\n1203.0 1659.0\n11493.0 1521.0049972237648\n21780.0 1365.0\n21795.75 8819.252082176568\n21837.0 16266.0\n11543.25 16300.500832870628\n1251.0 16332.0" | \ gdaltransform -tps -output_xy 7-4.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ 7-4.vrt 7-4.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES 7-4.cut.vrt 7-4.xyz