#!/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 2115.9056980853425 4680.625648660406 25.56210637 57.15683141 -gcp 18046.834349969322 2422.223949550411 25.55280447 57.21875454 -gcp 20021.985988704677 17887.992515905593 25.66315591 57.22377314 -gcp 3775.784878205266 18459.186956416153 25.66384792 57.16038079 GX10802/GX_10802_SK_frame_390.jpg GX_10802_SK_frame_390.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "672.0 2591.919777158774\n21264.0 2160.0267409470753\n21024.0 19007.973259052927\n864.0 19440.641782729806" | \ gdaltransform -tps -output_xy GX_10802_SK_frame_390.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_10802_SK_frame_390.vrt GX_10802_SK_frame_390.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_10802_SK_frame_390.cut.vrt GX_10802_SK_frame_390.xyz