#!/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 27.529820171367895 57.68469101899903 -gcp 14340.0 0.0 27.871155386245785 57.6857431709446 -gcp 14340.0 16389.0 27.872125563779342 57.47788663144701 -gcp 0.0 16389.0 27.53291609927452 57.477031983321446 261-Babina_1925.jpg 261-Babina_1925.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e \"7209.375 1454.6245835646862\n1959.0 1426.1239589117158\n1910.625 8005.125416435314\n1863.375 14582.251249305942\n7148.25 14609.438332870628\n12428.0625 14633.810730149919\n12444.75 8059.124791782342\n12471.0 1485.0\" | \ gdaltransform -tps -output_xy 261-Babina_1925.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}'))))" \ 261-Babina_1925.vrt 261-Babina_1925.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES 261-Babina_1925.cut.vrt 261-Babina_1925.xyz