#!/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 25.04059075 56.68870677 -gcp 13929.0 0.0 25.05302578 56.60587478 -gcp 13929.0 13899.0 24.90267456 56.59792589 -gcp 0.0 13899.0 24.88706946 56.68126051 GX10511/GX_10511_SK_frame_37.jpg GX_10511_SK_frame_37.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "264.0 1200.6670372429126\n13656.0 936.520289049472\n13608.0 12318.510283490828\n168.0 12335.986659255143" | \ gdaltransform -tps -output_xy GX_10511_SK_frame_37.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_10511_SK_frame_37.vrt GX_10511_SK_frame_37.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_10511_SK_frame_37.cut.vrt GX_10511_SK_frame_37.xyz