#!/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 24.479599 57.18404084 -gcp 14178.0 0.0 24.48566079 57.0987501 -gcp 14178.0 13992.0 24.3295455 57.09370318 -gcp 0.0 13992.0 24.32013692 57.18048395 GX10514/GX_10514_SK_frame_421.jpg GX_10514_SK_frame_421.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "432.0 1284.0\n13932.0 792.0\n13920.0 12612.0\n360.0 12492.0" | \ gdaltransform -tps -output_xy GX_10514_SK_frame_421.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_10514_SK_frame_421.vrt GX_10514_SK_frame_421.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_10514_SK_frame_421.cut.vrt GX_10514_SK_frame_421.xyz