#!/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.31395912 57.28761336 -gcp 21111.0 0.0 25.24706361 57.29059304 -gcp 21111.0 20736.0 25.24815795 57.32488164 -gcp 0.0 20736.0 25.31928062 57.32577985 GX954/GX_954R_SG_frame_6.jpg GX_954R_SG_frame_6.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "792.6892950391648 1704.9461410327594\n20814.0 1335.0\n20711.958224543083 18743.986674069958\n678.0 18609.0" | \ gdaltransform -tps -output_xy GX_954R_SG_frame_6.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_954R_SG_frame_6.vrt GX_954R_SG_frame_6.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_954R_SG_frame_6.cut.vrt GX_954R_SG_frame_6.xyz