#!/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.521197557449 56.638512966951 -gcp 11583.0 0.0 21.51487827301 56.609095926503 -gcp 11583.0 13128.0 21.454367637634 56.613158069789 -gcp 0.0 13128.0 21.46121263504 56.642518851268 Aizpute-1988-991/Aizpute-1988-991-85.jpg Aizpute-1988-991-85.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "543.0 1845.0\n10311.0 495.0\n10974.0 5418.0\n11490.0 10338.0\n1893.0 11664.0" | \ gdaltransform -tps -output_xy Aizpute-1988-991-85.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ Aizpute-1988-991-85.vrt Aizpute-1988-991-85.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES Aizpute-1988-991-85.cut.vrt Aizpute-1988-991-85.xyz