View source: R/extract_feature.R
| extract_feature | R Documentation |
Extract a numeric or logical summary from segmented raster regions using a user-defined reducer, returning one value per segment as a raster map or a named vector.
extract_feature(
r,
segmentation,
fun = mean,
return = "raster",
ignore_label_0 = TRUE
)
r |
numeric terra::SpatRaster with one layer. |
segmentation |
single-layer terra::SpatRaster. Segmentation map
of r, typically created with functions such as |
fun |
function taking a numeric/logical vector and returning a single
numeric or logical value (default |
return |
character of length one. Either |
ignore_label_0 |
logical of length one. If |
Segments labeled 0 can be ignored via ignore_label_0 = TRUE. The
function in fun must return a single numeric or logical value for any input
vector (e.g., mean, median, or a custom reducer).
If return = "raster", a terra::SpatRaster where each pixel
holds its segment’s feature value. If return = "vector", a named numeric
(or logical) vector with one value per segment.
r <- read_caim()
z <- zenith_image(ncol(r),lens())
a <- azimuth_image(z)
g <- sky_grid_segmentation(z, a, 10)
print(extract_feature(r$Blue, g, return = "vector"))
# plot(extract_feature(r$Blue, g, return = "raster"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.