Hi.

Here comes a bit more polished script version. The results are joined into a multiband GeoTiff file.

________________________________
INPUT=MultidimensionGrid
INPUT_EXT=tif
TMP_SAGA=MultiDim
FOCAL_CMD=MEDIAN

for NR in {0..5} ; do
        echo -ne "\033]0;Working with Band $NR\007"
        saga_cmd io_gdal 0 \
                -GRIDS $TMP_SAGA$NR -MULTIPLE 0 \
                -SELECTION  $NR \
                -FILES $INPUT.$INPUT_EXT
        saga_cmd statistics_grid 1 \
                -GRID $TMP_SAGA$NR.sgrd  \
                -$FOCAL_CMD $FOCAL_CMD$NR
        rm $TMP_SAGA$NR.*
        JOIN=$JOIN$FOCAL_CMD$NR'.sgrd'\;
done

JOIN=${JOIN%;}
saga_cmd io_gdal 1 \
        -GRIDS $JOIN \
        -MULTIPLE 1 -FILE $INPUT'_'$FOCAL_CMD.tiff \
        -FORMAT GeoTIFF \
        -OPTIONS COMPRESS=DEFLATE PREDICTOR=2

rm $FOCAL_CMD*

________________________________

B.r.
K.


01.01.26 15:50, Karlo no Dabas maajas via QGIS-User rakstīja:
Hi again!

„Focal Statistics” works only with one layer. But it's easy to overcome this with small script.

Look at this example. As the source, I have a GeoTIFF with 6 bands:

[..]


So I create a script to calculate median for all bands:

[..]
_______________________________________________
QGIS-User mailing list
[email protected]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user

Reply via email to