#!/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.22416687 56.97838572 -gcp 21414.0 0.0 24.26600933 57.07419547 -gcp 21414.0 21789.0 24.4372201 57.04909907 -gcp 0.0 21789.0 24.39939022 56.9588759 GX2206/GX_2206_SK_frame_51.jpg GX_2206_SK_frame_51.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "444.0 3312.0\n396.0 10254.0\n708.0 10479.0\n720.0 11913.0\n408.0 12177.0\n378.0 18717.0\n21147.0 19113.0\n21144.0 3024.0" | \ gdaltransform -tps -output_xy GX_2206_SK_frame_51.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_2206_SK_frame_51.vrt GX_2206_SK_frame_51.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_2206_SK_frame_51.cut.vrt GX_2206_SK_frame_51.xyz