#!/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.264162683892 56.637152763415 -gcp 11319.0 0.0 21.254470447949 56.60824293265 -gcp 11319.0 12423.0 21.19721223295 56.614146716049 -gcp 0.0 12423.0 21.207161960959 56.642640393745 Aizpute-1988-991/Aizpute-1988-991-96.jpg Aizpute-1988-991-96.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "15.0 1930.5\n15.0 2227.5\n1785.75 11647.5\n11310.0 9834.0\n11316.0 8872.5\n9646.5 82.5" | \ gdaltransform -tps -output_xy Aizpute-1988-991-96.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ Aizpute-1988-991-96.vrt Aizpute-1988-991-96.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES Aizpute-1988-991-96.cut.vrt Aizpute-1988-991-96.xyz