#!/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.94327215 56.65651307 -gcp 14331.0 0.0 24.94381934 56.74107815 -gcp 14331.0 14253.0 25.09336889 56.74152464 -gcp 0.0 14253.0 25.09596371 56.65763938 GX10504/GX_10504_SK_frame_844.jpg GX_10504_SK_frame_844.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "576.0 1344.7470817120623\n13872.0 1128.627015008338\n13824.0 12630.683713173985\n648.0 12630.683713173985" | \ gdaltransform -tps -output_xy GX_10504_SK_frame_844.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_10504_SK_frame_844.vrt GX_10504_SK_frame_844.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_10504_SK_frame_844.cut.vrt GX_10504_SK_frame_844.xyz