#!/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 4269.0 1785.0 20.837216666666666 56.25 -gcp 26256.0 2007.0 21.337216666666666 56.25 -gcp 26163.0 21759.0 21.337216666666666 56 -gcp 4041.0 21522.0 20.837216666666666 56 nr/KdwR-LC_H17_Dorbiany.jpg KdwR-LC_H17_Dorbiany.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "4269.0 1785.0\n26256.0 2007.0\n26163.0 21759.0\n4041.0 21522.0" | \ gdaltransform -tps -output_xy KdwR-LC_H17_Dorbiany.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ KdwR-LC_H17_Dorbiany.vrt KdwR-LC_H17_Dorbiany.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES KdwR-LC_H17_Dorbiany.cut.vrt KdwR-LC_H17_Dorbiany.xyz