#!/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.24248099 56.85860442 -gcp 14382.0 0.0 24.40238893 56.85812638 -gcp 14382.0 14718.0 24.39728737 56.77008288 -gcp 0.0 14718.0 24.24385428 56.77256391 GX10673/GX_10673_SK_frame_01.jpg GX_10673_SK_frame_01.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "564.0 852.0\n12888.0 936.0\n13368.0 13092.0\n492.0 13008.0" | \ gdaltransform -tps -output_xy GX_10673_SK_frame_01.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_10673_SK_frame_01.vrt GX_10673_SK_frame_01.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_10673_SK_frame_01.cut.vrt GX_10673_SK_frame_01.xyz