#!/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 759.0 651.0 21.5 57.666666666666664 -gcp 7785.0 660.0 22 57.666666666666664 -gcp 7830.0 9408.0 22 57.333333333333336 -gcp 684.0 9378.0 21.5 57.333333333333336 O-34-92_Ventspils.jpg O-34-92_Ventspils.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "249.0 8497.496229260934\n729.0 8504.997737556561\n759.0 651.0\n7785.0 660.0\n7830.0 9408.0\n237.0 9372.0" | \ gdaltransform -tps -output_xy O-34-92_Ventspils.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ O-34-92_Ventspils.vrt O-34-92_Ventspils.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES O-34-92_Ventspils.cut.vrt O-34-92_Ventspils.xyz