#!/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.74756241 56.65278236 -gcp 21540.0 0.0 24.75133896 56.73801469 -gcp 21540.0 23217.0 24.91263628 56.73647294 -gcp 0.0 23217.0 24.91501808 56.65304186 GX10504/GX_10504_SK_frame_847.jpg GX_10504_SK_frame_847.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "840.0 2448.0\n864.0 19464.0\n20832.0 19824.0\n21096.0 2400.0" | \ gdaltransform -tps -output_xy GX_10504_SK_frame_847.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_10504_SK_frame_847.vrt GX_10504_SK_frame_847.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_10504_SK_frame_847.cut.vrt GX_10504_SK_frame_847.xyz