#!/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.328293085098 56.639138361302 -gcp 10512.0 0.0 21.328496932983 56.612077629564 -gcp 10512.0 12363.0 21.271290779114 56.611959546792 -gcp 0.0 12363.0 21.270722150803 56.638931864314 Aizpute-1988-991/Aizpute-1988-991-93.jpg Aizpute-1988-991-93.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "330.0 1158.0\n10197.0 1029.0\n10311.0 10950.0\n450.0 11064.0" | \ gdaltransform -tps -output_xy Aizpute-1988-991-93.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ Aizpute-1988-991-93.vrt Aizpute-1988-991-93.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES Aizpute-1988-991-93.cut.vrt Aizpute-1988-991-93.xyz