#!/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 25.19609213 57.07199095 -gcp 14289.0 0.0 25.02163589 57.06369398 -gcp 14289.0 14040.0 25.01796126 57.15982269 -gcp 0.0 14040.0 25.18699408 57.1595783 GX2206/GX_2206_SK_frame_83.jpg GX_2206_SK_frame_83.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "1536.0 599.9197771587742\n12840.0 504.1203342618387\n12456.0 13656.133704735377\n1080.0 13656.026740947076" | \ gdaltransform -tps -output_xy GX_2206_SK_frame_83.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_2206_SK_frame_83.vrt GX_2206_SK_frame_83.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_2206_SK_frame_83.cut.vrt GX_2206_SK_frame_83.xyz