#!/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 3493.0408857460197 4341.441407426714 24.26264048 56.785766 -gcp 18688.462582246964 2738.1165684653142 24.25307035 56.84497039 -gcp 18016.234439673914 20445.6451962842 24.3818593 56.84200098 -gcp 2776.808524528176 20423.98824266095 24.37987447 56.78129911 GX10673/GX_10673_SK_frame_001.jpg GX_10673_SK_frame_001.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "684.0 3491.839588688946\n20544.0 3120.3208226221077\n20640.0 20448.074035989717\n672.0 20210.418508997427" | \ gdaltransform -tps -output_xy GX_10673_SK_frame_001.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_10673_SK_frame_001.vrt GX_10673_SK_frame_001.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_10673_SK_frame_001.cut.vrt GX_10673_SK_frame_001.xyz