#!/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.9524107 57.71038346 -gcp 21240.0 0.0 25.85100174 57.77193147 -gcp 21240.0 21510.0 25.97768784 57.84794848 -gcp 0.0 21510.0 26.10437393 57.76218057 GX954/GX_954_SK_frame_23.jpg GX_954_SK_frame_23.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "768.0 2447.9199555308496\n20880.0 1919.9733185102823\n20880.0 19200.08004446915\n768.0 19584.21345191773" | \ gdaltransform -tps -output_xy GX_954_SK_frame_23.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_954_SK_frame_23.vrt GX_954_SK_frame_23.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_954_SK_frame_23.cut.vrt GX_954_SK_frame_23.xyz