#!/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.49918959504 56.637925961821 -gcp 12150.0 0.0 21.489658482354 56.607223796827 -gcp 12150.0 13485.0 21.427763299416 56.612913065387 -gcp 0.0 13485.0 21.437525082078 56.643597627568 Aizpute-1988-991/Aizpute-1988-991-86.jpg Aizpute-1988-991-86.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "315.0 2283.0\n10041.0 456.0\n11853.0 10194.0\n2121.0 12003.0" | \ gdaltransform -tps -output_xy Aizpute-1988-991-86.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ Aizpute-1988-991-86.vrt Aizpute-1988-991-86.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES Aizpute-1988-991-86.cut.vrt Aizpute-1988-991-86.xyz