#!/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.356696974865 56.555045139514 -gcp 10572.0 0.0 21.356337379258 56.528157891068 -gcp 10572.0 12510.0 21.298996559479 56.527987772864 -gcp 0.0 12510.0 21.298760704685 56.555046624848 Aizpute-1988-991/Aizpute-1988-991-38.jpg Aizpute-1988-991-38.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "31.5 6160.5\n60.0 1194.0\n9807.0 999.0\n9990.0 10926.0\n126.0 11101.5" | \ gdaltransform -tps -output_xy Aizpute-1988-991-38.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ Aizpute-1988-991-38.vrt Aizpute-1988-991-38.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES Aizpute-1988-991-38.cut.vrt Aizpute-1988-991-38.xyz