#!/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 4626.0000000000755 6201.528579846816 22.60299683 57.76939488 -gcp 14504.060002587175 6787.262975704844 27.53997803 57.52761826 -gcp 15038.961264389976 13307.81636153184 27.61138916 55.79973049 -gcp 1548.000000000084 12019.085444902781 21.13082886 56.17156062 -gcp 7513.030743743944 8822.198634424278 24.02641296 57.06164367 -gcp 9265.5 11084.39938126105 24.89055634 56.4488597 k_001_ktl1-4-48_1.jpg k_001_ktl1-4-48_1.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "0.0 0.0\n16740.0 0.0\n16740.0 20880.0\n0.0 20880.0" | \ gdaltransform -tps -output_xy k_001_ktl1-4-48_1.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ k_001_ktl1-4-48_1.vrt k_001_ktl1-4-48_1.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES k_001_ktl1-4-48_1.cut.vrt k_001_ktl1-4-48_1.xyz