#!/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.63795662 56.97775427 -gcp 21414.0 0.0 24.68499184 57.07449872 -gcp 21414.0 21666.0 24.85266209 57.04614613 -gcp 0.0 21666.0 24.81217146 56.95816222 GX2206/GX_2206_SK_frame_43.jpg GX_2206_SK_frame_43.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "1200.0 2736.0\n1032.0 19248.0\n20784.0 19344.0\n20832.0 2928.0" | \ gdaltransform -tps -output_xy GX_2206_SK_frame_43.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_2206_SK_frame_43.vrt GX_2206_SK_frame_43.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_2206_SK_frame_43.cut.vrt GX_2206_SK_frame_43.xyz