#!/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.90809798 56.55650845 -gcp 14331.0 0.0 24.91787195 56.64139205 -gcp 14331.0 13824.0 25.06920218 56.63733295 -gcp 0.0 13824.0 25.05911708 56.54982047 GX10508/GX_10508B_SK_frame_910.jpg GX_10508B_SK_frame_910.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "431.94913596348215 1296.0\n13752.089990218454 1092.0\n13800.058689272904 12516.0\n587.9647864362569 12564.0" | \ gdaltransform -tps -output_xy GX_10508B_SK_frame_910.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_10508B_SK_frame_910.vrt GX_10508B_SK_frame_910.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_10508B_SK_frame_910.cut.vrt GX_10508B_SK_frame_910.xyz