#!/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.372581720352176 56.68273109457638 -gcp 10581.0 0.0 21.372474431992 56.655394975609 -gcp 10581.0 12033.0 21.315906643867 56.655389078254 -gcp 0.0 12033.0 21.316147261264 56.682860490266 Aizpute-1988-991/Aizpute-1988-991-118.jpg Aizpute-1988-991-118.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "414.0 786.0\n10266.0 558.0\n10485.0 10449.0\n627.0 10669.5" | \ gdaltransform -tps -output_xy Aizpute-1988-991-118.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ Aizpute-1988-991-118.vrt Aizpute-1988-991-118.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES Aizpute-1988-991-118.cut.vrt Aizpute-1988-991-118.xyz