#!/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.3269062 57.03012843 -gcp 21564.0 0.0 24.36308384 56.9308097 -gcp 21564.0 21444.0 24.18951273 56.91655784 -gcp 0.0 21444.0 24.15593147 57.00543459 GX2206/GX_2206_SK_frame_20.jpg GX_2206_SK_frame_20.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "720.0 2975.812813370473\n21048.0 2927.893036211699\n21384.0 19199.745961002787\n1056.0 18815.598885793872" | \ gdaltransform -tps -output_xy GX_2206_SK_frame_20.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_2206_SK_frame_20.vrt GX_2206_SK_frame_20.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_2206_SK_frame_20.cut.vrt GX_2206_SK_frame_20.xyz