#!/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 2766.0 2277.0 24.626666666666665 57.333333333333336 -gcp 15543.0 2175.0 24.926666666666666 57.333333333333336 -gcp 15567.0 15378.0 24.926666666666666 57.166666666666664 -gcp 2766.0 15438.0 24.626666666666665 57.166666666666664 028_Loddiger_w.y.jpg 028_Loddiger_w.y.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "2766.0 2277.0\n15543.0 2175.0\n15567.0 15378.0\n2766.0 15438.0" | \ gdaltransform -tps -output_xy 028_Loddiger_w.y.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ 028_Loddiger_w.y.vrt 028_Loddiger_w.y.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES 028_Loddiger_w.y.cut.vrt 028_Loddiger_w.y.xyz