#!/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 27.71696091 56.5348022 -gcp 21819.0 0.0 27.6905716 56.55421746 -gcp 21819.0 21252.0 27.72211438 56.56850099 -gcp 0.0 21252.0 27.75071383 56.55019896 GX644/GX_644_SD_frame_94.jpg GX_644_SD_frame_94.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "984.0 2639.893036211699\n20904.0 2759.705849582172\n21144.0 19391.75933147632\n744.0 19248.026740947076" | \ gdaltransform -tps -output_xy GX_644_SD_frame_94.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_644_SD_frame_94.vrt GX_644_SD_frame_94.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_644_SD_frame_94.cut.vrt GX_644_SD_frame_94.xyz