#!/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.07379773 57.07095382 -gcp 42708.0 0.0 26.07974461 56.98800423 -gcp 42708.0 42588.0 25.92474084 56.98415544 -gcp 0.0 42588.0 25.91924286 57.06839537 GX220/GX_220_SK_frame_588.jpg GX_220_SK_frame_588.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "2544.0 3552.0\n2496.0 37680.0\n40368.0 37968.0\n40416.0 3216.0" | \ gdaltransform -tps -output_xy GX_220_SK_frame_588.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_220_SK_frame_588.vrt GX_220_SK_frame_588.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_220_SK_frame_588.cut.vrt GX_220_SK_frame_588.xyz