#!/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 1464.0 723.0 20.958333333333332 56.75 -gcp 12198.0 714.0 21.333333333333332 56.75 -gcp 12279.0 13866.0 21.333333333333332 56.5 -gcp 1407.0 13872.0 20.958333333333332 56.5 k_001_ktl2-1-85-a_004.jpg k_001_ktl2-1-85-a_004.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "1441.5 4296.751250694831\n2214.75 4298.251250694831\n2220.0 3673.2836297943304\n2639.25 3672.838799332963\n2640.0 3353.249583101723\n2173.5 3351.5286270150086\n2172.0 3826.5\n1458.0 3831.0900500277935\n1464.0 723.0\n12198.0 714.0\n12279.0 13866.0\n1407.0 13872.0" | \ gdaltransform -tps -output_xy k_001_ktl2-1-85-a_004.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ k_001_ktl2-1-85-a_004.vrt k_001_ktl2-1-85-a_004.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES k_001_ktl2-1-85-a_004.cut.vrt k_001_ktl2-1-85-a_004.xyz