#!/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 3807.0 2472.0 27 56 -gcp 21420.0 2457.0 30 56 -gcp 21843.0 23364.0 30 54 -gcp 3312.0 23403.0 27 54 N-35-B_POLOCK_6.1940.jpg N-35-B_POLOCK_6.1940.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "3807.0 2472.0\n12615.0 2583.065036131184\n21420.0 2457.0\n21843.0 23364.0\n12606.0 23508.0683713174\n3312.0 23403.0" | \ gdaltransform -tps -output_xy N-35-B_POLOCK_6.1940.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ N-35-B_POLOCK_6.1940.vrt N-35-B_POLOCK_6.1940.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES N-35-B_POLOCK_6.1940.cut.vrt N-35-B_POLOCK_6.1940.xyz