#!/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 5552.462763292221 2918.6452442303225 25.49363762 57.28020843 -gcp 18971.738450324217 3309.019536950474 25.49624741 57.33252374 -gcp 18458.672853275162 18880.584449466387 25.6103003 57.33033165 -gcp 901.9348026761628 14434.787250651589 25.57784557 57.26225781 GX8464/GX_8464_SK_frame_273.jpg GX_8464_SK_frame_273.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "408.0 2423.959888579387\n21288.0 2423.893036211699\n20904.0 19872.33426183844\n432.0 19344.66852367688" | \ gdaltransform -tps -output_xy GX_8464_SK_frame_273.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_8464_SK_frame_273.vrt GX_8464_SK_frame_273.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_8464_SK_frame_273.cut.vrt GX_8464_SK_frame_273.xyz