#!/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.05889988 56.86267488 -gcp 21627.0 0.0 24.0397999 56.77529131 -gcp 21627.0 21444.0 23.86509154 56.77818346 -gcp 0.0 21444.0 23.88715267 56.88185988 GX2261/GX_2261_SK_frame_80.jpg GX_2261_SK_frame_80.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "2208.0 1776.588300835656\n16944.0 1440.0267409470753\n17232.0 19248.454596100277\n2304.0 19535.8930362117" | \ gdaltransform -tps -output_xy GX_2261_SK_frame_80.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_2261_SK_frame_80.vrt GX_2261_SK_frame_80.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_2261_SK_frame_80.cut.vrt GX_2261_SK_frame_80.xyz