#!/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 0.0 0.0 21.335567235946662 56.53738161127411 -gcp 11319.0 0.0 21.339987516403202 56.508542897223876 -gcp 11319.0 13017.0 21.280442476272583 56.50555894486505 -gcp 0.0 13017.0 21.275721788406372 56.53438806503569 Aizpute-1988-991/Aizpute-1988-991-18.jpg Aizpute-1988-991-18.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "984.0 1236.0\n430.5 11125.5\n10302.0 11668.5\n10830.0 1753.5" | \ gdaltransform -tps -output_xy Aizpute-1988-991-18.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ Aizpute-1988-991-18.vrt Aizpute-1988-991-18.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES Aizpute-1988-991-18.cut.vrt Aizpute-1988-991-18.xyz