Last chance! 50% off unlimited learning
Sale ends in
For each band and for each cell, depending of specification, function finds either minimal or maximal value inside of square window. Focal operation of map algebra.
focal_extrem(x, kind = c("min", "max"), size = 3, cover = 1e-06,
fillNA = FALSE, saveMargin = TRUE, verbose = 0L)
focal_min(x, size = 3, cover = 1e-06, fillNA = FALSE, saveMargin = TRUE, verbose = 0L)
focal_max(x, size = 3, cover = 1e-06, fillNA = FALSE, saveMargin = TRUE, verbose = 0L)
Object of class ursaRaster
.
Character. What kind of extremum is required. Allowed values "min"
or "max"
.
Positive numeric. Odd values (3, 5, 7, …) are allowed, but if other value is specified, then it expanded to the next odd value not less than original value. Default is 3L
.
Numeric. 0<=cover<=1
. Quota for NA
values in the focal window in relation to the squared size of the focal window. Quota exceeding leads to recording NA
value in the cell. Default is cover=1e-6
.
Logical. If TRUE
then only NA
values of source image can be changed, and non-NA
values of source image are kept without changes. It may provide less reducing of spatial resolution in the task of spatial interpolation. Default is FALSE
.
Logical. If TRUE
then adaptive window size is used for cells, where original window goes over image boundary. If FALSE
then image is expanded to the half size of focal window by NA
values and argument cover
is applied to this expanded part. Default is TRUE
.
Integer of 0L
, 1L
, or 2L
, or logical, which is coerced to integer. The level of verbosity. Values >0
provide some additional information on console, verbose=1L
is less detailed, verbose=2L
is more detailed. Default is 0L
.
Object of class ursaRaster
with the same number of bands as in input raster.
focal_min(x,...)
is a wrapper to focal_extrem(x,"min",...)
focal_max(x,...)
is a wrapper to focal_extrem(x,"max",...)
Other focal operations: focal_mean
, focal_median
.
# NOT RUN {
session_grid(NULL)
a <- ursa_dummy(nband=2,mul=1/8,elements=32)
a[a<80] <- NA
b.min <- focal_extrem(a,"min",size=4,cover=0.5,verbose=1L)
b.max <- focal_extrem(a,"max",size=4,cover=0.5,verbose=1L)
print(list(src=a,min=b.min,max=b.max,dif=b.max-b.min))
# }
Run the code above in your browser using DataLab