#!/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 1953.1599570683352 6744.774480159639 25.63689709 57.26618318 -gcp 17380.976611691818 3329.1722928049785 25.6143558 57.32667754 -gcp 15048.80456015463 19002.36061884239 25.72762012 57.31585083 -gcp 2531.3181962488547 18165.729912677267 25.71988463 57.26738979 GX8464/GX_8464_SK_frame_271.jpg GX_8464_SK_frame_271.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "528.0 2447.939668174962\n21216.0 2351.855203619907\n20880.0 19260.066365007544\n432.0 19344.24132730015" | \ gdaltransform -tps -output_xy GX_8464_SK_frame_271.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_8464_SK_frame_271.vrt GX_8464_SK_frame_271.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_8464_SK_frame_271.cut.vrt GX_8464_SK_frame_271.xyz