#!/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 1311.0 1512.0 25.429566666666666 57.33153333333333 -gcp 22044.0 1689.0 26.647333333333332 57.37153333333333 -gcp 22005.0 16407.0 26.69558333333333 56.89803333333333 -gcp 1317.0 16410.0 25.490083333333335 56.85845 1915_3verst_ru_126k/8-5.jpg 8-5.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "1300.5 8962.500832870628\n1311.0 1512.0\n11676.0 1576.4866740699613\n22044.0 1689.0\n22020.0 9049.500832870628\n22005.0 16407.0\n11670.0 16390.50666296502\n1317.0 16410.0" | \ gdaltransform -tps -output_xy 8-5.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ 8-5.vrt 8-5.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES 8-5.cut.vrt 8-5.xyz