#!/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.33812046 57.29913818 -gcp 21111.0 0.0 25.18948283 57.29942795 -gcp 21111.0 21186.0 25.16781058 57.39430571 -gcp 0.0 21186.0 25.36202431 57.39302228 GX954/GX_954_SK_frame_13.jpg GX_954_SK_frame_13.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "552.0 2039.9866592551418\n20592.0 1920.3468593663138\n20664.0 18936.01334074486\n432.0 19152.08004446915" | \ gdaltransform -tps -output_xy GX_954_SK_frame_13.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_954_SK_frame_13.vrt GX_954_SK_frame_13.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_954_SK_frame_13.cut.vrt GX_954_SK_frame_13.xyz