#!/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 26.71289875 56.77600665 -gcp 22464.0 0.0 26.72251179 56.86258989 -gcp 22464.0 21186.0 26.87443444 56.857113 -gcp 0.0 21186.0 26.86210201 56.76988339 GX10673/GX_10673_SK_frame_958.jpg GX_10673_SK_frame_958.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "1080.0 2160.0\n20616.0 1848.0\n20760.0 19320.0\n1056.0 19152.0" | \ gdaltransform -tps -output_xy GX_10673_SK_frame_958.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_10673_SK_frame_958.vrt GX_10673_SK_frame_958.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_10673_SK_frame_958.cut.vrt GX_10673_SK_frame_958.xyz