#!/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 2130.0 2322.0 24.476666666666667 56.916666666666664 -gcp 15117.0 2292.0 24.626666666666665 56.916666666666664 -gcp 15159.0 15711.0 24.626666666666665 56.833333333333336 -gcp 2133.0 15708.0 24.476666666666667 56.833333333333336 105_Ukskul_12.11.17.jpg 105_Ukskul_12.11.17.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "2130.0 2322.0\n15117.0 2292.0\n15159.0 15711.0\n2133.0 15708.0" | \ gdaltransform -tps -output_xy 105_Ukskul_12.11.17.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ 105_Ukskul_12.11.17.vrt 105_Ukskul_12.11.17.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES 105_Ukskul_12.11.17.cut.vrt 105_Ukskul_12.11.17.xyz