A couple of thousand DEM geotiffs are erroring out in QGIS GRASS r.neighbors function using these parameters
GRASS r.neighbors neighborhood operation=range, neighborhood size=3
with the following error :-
2021-04-23T15:51:51 WARNING Duplicate parameter coordinates registered for alg v.net.visibility
I wanted to replicate this operation in R.
Looks like the only built in focal() functions are mean(), var() not range()? And the exact extents of the output raster does not match the input raster extents unlike GRASS?
Is there a matrix expression equivalent of the GRASS r.neighbors neighborhood operation=range, neighborhood size=3 in the focal() function or in R in general?
I assume that with "range" you refer to the difference between the focal min and max value? You can compute that in (at least) two ways
or like this
The results are slightly different where there are NAs. You can use
na.rm=TRUE
.