#!/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 24.49590683 57.75064089 -gcp 21306.0 0.0 24.36145306 57.76149378 -gcp 21306.0 21897.0 24.37510201 57.84186118 -gcp 0.0 21897.0 24.52908039 57.82791383 GX4194/GX_4194_SG_frame_4.jpg GX_4194_SG_frame_4.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "816.0 2927.8662952646237\n20928.0 2160.0534818941505\n21168.0 20015.625626740948\n768.0 19920.213927576602" | \ gdaltransform -tps -output_xy GX_4194_SG_frame_4.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_4194_SG_frame_4.vrt GX_4194_SG_frame_4.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_4194_SG_frame_4.cut.vrt GX_4194_SG_frame_4.xyz