#!/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 2873.9689001296674 5904.853643043685 25.0821358 57.17316977 -gcp 19962.297729855793 3968.5499388768103 25.10316968 57.10540552 -gcp 20026.485475510966 18813.20141734119 24.99579549 57.10077843 -gcp 3161.695902479806 18077.487767639665 24.99194384 57.16919867 GX10514/GX_10514_SK_frame_434.jpg GX_10514_SK_frame_434.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "720.0 3623.913624678663\n20616.0 3071.420051413882\n20616.0 20688.111053984576\n960.0 20616.57994858612" | \ gdaltransform -tps -output_xy GX_10514_SK_frame_434.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_10514_SK_frame_434.vrt GX_10514_SK_frame_434.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_10514_SK_frame_434.cut.vrt GX_10514_SK_frame_434.xyz