#!/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 2740.3808501032645 5946.9886344252645 24.91951346 57.26737259 -gcp 19962.319298595943 3994.353297699852 24.90415514 57.33687844 -gcp 18532.086802487564 17663.868595168267 25.00471115 57.33126457 -gcp 1467.5980881452356 18658.63486703895 25.01353025 57.26276306 GX8464/GX_8464_SK_frame_283.jpg GX_8464_SK_frame_283.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "816.0 2591.9732590529247\n576.0 19296.187186629526\n20784.0 19680.08022284122\n21024.0 2352.641782729805" | \ gdaltransform -tps -output_xy GX_8464_SK_frame_283.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_8464_SK_frame_283.vrt GX_8464_SK_frame_283.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_8464_SK_frame_283.cut.vrt GX_8464_SK_frame_283.xyz