#!/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 25.152465480148837 57.419839910473044 -gcp 17004.0 0.0 25.554787615355437 57.42042248118554 -gcp 17004.0 19380.0 25.55357013943811 57.17348768928927 -gcp 0.0 19380.0 25.15228221241384 57.17403892919608 Cesis.jpg Cesis.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e \"2014.6875 1565.061979455858\n2008.125 9460.88228761799\n2028.9375 17330.063645197115\n14737.125 17310.0\n14712.75 9466.507495835647\n14700.375 1596.3752082176568\" | \ gdaltransform -tps -output_xy Cesis.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}'))))" \ Cesis.vrt Cesis.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES Cesis.cut.vrt Cesis.xyz