#!/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 1311.6926367022968 1625.6689712547256 25.28155133 57.30279617 -gcp 39624.85008570892 1615.759202343284 25.25772661 57.31220503 -gcp 38052.850493261154 30975.8261447637 25.27248144 57.32220597 -gcp 2770.6672507545845 31103.21890743233 25.29460162 57.31282212 GX5131/c_GX_5131_SK_frame_18.jpg c_GX_5131_SK_frame_18.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "0.0 0.0\n41343.0 0.0\n41343.0 32616.0\n0.0 32616.0" | \ gdaltransform -tps -output_xy c_GX_5131_SK_frame_18.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ c_GX_5131_SK_frame_18.vrt c_GX_5131_SK_frame_18.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES c_GX_5131_SK_frame_18.cut.vrt c_GX_5131_SK_frame_18.xyz