#!/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 1520.8284582847698 2680.8410516107497 27.23281682 57.1477269 -gcp 18528.230663439892 3197.932116253528 27.24288046 57.21406352 -gcp 21036.32215495277 18721.10446305743 27.35623598 57.22093263 -gcp 4328.321153556558 17282.123536161478 27.33813643 57.1548495 GX10802/GX_10802_SK_frame_359.jpg GX_10802_SK_frame_359.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "576.0 2595.0\n20904.0 2375.799442896936\n20856.0 19751.826183844012\n864.0 19704.574930362116" | \ gdaltransform -tps -output_xy GX_10802_SK_frame_359.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_10802_SK_frame_359.vrt GX_10802_SK_frame_359.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_10802_SK_frame_359.cut.vrt GX_10802_SK_frame_359.xyz