#!/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 23.86419296 56.99077874 -gcp 21564.0 0.0 23.91079903 57.08497086 -gcp 21564.0 21573.0 24.07660086 57.06134349 -gcp 0.0 21573.0 24.03718472 56.97052688 GX2206/GX_2206_SK_frame_58.jpg GX_2206_SK_frame_58.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "888.0 2880.1604456824516\n21000.0 3047.8796657381613\n21096.0 19872.374373259052\n3432.0 19896.521448467967\n1008.0 18719.91977715878" | \ gdaltransform -tps -output_xy GX_2206_SK_frame_58.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_2206_SK_frame_58.vrt GX_2206_SK_frame_58.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_2206_SK_frame_58.cut.vrt GX_2206_SK_frame_58.xyz