#!/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 3480.0 2061.0 24.476666666666667 57.166666666666664 -gcp 16206.0 2016.0 24.626666666666665 57.166666666666664 -gcp 16320.0 15177.0 24.626666666666665 57.083333333333336 -gcp 3558.0 15246.0 24.476666666666667 57.083333333333336 142_Murjan_29.9.17.jpg 142_Murjan_29.9.17.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "3480.0 2061.0\n16206.0 2016.0\n16320.0 15177.0\n3558.0 15246.0" | \ gdaltransform -tps -output_xy 142_Murjan_29.9.17.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ 142_Murjan_29.9.17.vrt 142_Murjan_29.9.17.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES 142_Murjan_29.9.17.cut.vrt 142_Murjan_29.9.17.xyz