#!/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.71213841 57.15001149 -gcp 14247.0 0.0 25.71943402 57.2325424 -gcp 14247.0 14169.0 25.87191224 57.23111391 -gcp 0.0 14169.0 25.86869359 57.14614694 GX10802/GX_10802_SK_frame_387.jpg GX_10802_SK_frame_387.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "432.0 1512.8404669260701\n13872.0 1391.9199555308503\n13896.0 12582.657031684268\n456.0 12510.617009449696" | \ gdaltransform -tps -output_xy GX_10802_SK_frame_387.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_10802_SK_frame_387.vrt GX_10802_SK_frame_387.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_10802_SK_frame_387.cut.vrt GX_10802_SK_frame_387.xyz