#!/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 846.0 1239.0 24.926666666666666 56.333333333333336 -gcp 13995.0 1209.0 25.076666666666668 56.333333333333336 -gcp 14022.0 14388.0 25.076666666666668 56.25 -gcp 807.0 14394.0 24.926666666666666 56.25 Gruppe_Riga/VI-18-G.jpeg VI-18-G.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "846.0 1239.0\n13995.0 1209.0\n14022.0 14388.0\n807.0 14394.0" | \ gdaltransform -tps -output_xy VI-18-G.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ VI-18-G.vrt VI-18-G.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES VI-18-G.cut.vrt VI-18-G.xyz