#!/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 1716.0 2568.0 24.776666666666667 56.583333333333336 -gcp 14718.0 2415.0 24.926666666666666 56.583333333333336 -gcp 14895.0 15588.0 24.926666666666666 56.5 -gcp 1863.0 15768.0 24.776666666666667 56.5 088_Wistul_29.8.17.jpg 088_Wistul_29.8.17.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "1716.0 2568.0\n14718.0 2415.0\n14895.0 15588.0\n1863.0 15768.0" | \ gdaltransform -tps -output_xy 088_Wistul_29.8.17.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ 088_Wistul_29.8.17.vrt 088_Wistul_29.8.17.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES 088_Wistul_29.8.17.cut.vrt 088_Wistul_29.8.17.xyz