#!/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 26.228255395106313 57.35451980721653 -gcp 16476.0 0.0 26.618676500999975 57.355223131148186 -gcp 16476.0 16611.0 26.617206434248246 57.14447463039934 -gcp 0.0 16611.0 26.230242726775952 57.14389040081599 203-Velena_1924.jpg 203-Velena_1924.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e \"2037.0 1671.0\n1985.25 14811.750416435316\n14744.25 14847.0\n14709.0 1710.0\" | \ gdaltransform -tps -output_xy 203-Velena_1924.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}'))))" \ 203-Velena_1924.vrt 203-Velena_1924.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES 203-Velena_1924.cut.vrt 203-Velena_1924.xyz