Skip to contents

These functions manipulate segmetric objects.

  • sm_read(): Load the reference and segmentation polygons into segmetric.

  • sm_clear(): Remove the already calculated metrics from segmetric.

  • print(): Print a segmetric object.

  • plot(): Plot the reference and segmentation polygons.

  • summary(): Compute a measure of central tendency over the values of a metric.

  • sm_is_empty(): Check if a segmetric object is empty.

Usage

.segmetric_check(m)

.segmetric_env(m)

sm_read(ref_sf, seg_sf)

sm_clear(m)

# S3 method for segmetric
summary(object, weight = NULL, na_rm = TRUE, ...)

sm_is_empty(m)

# S3 method for segmetric
[(x, i)

Arguments

m

A segmetric object.

ref_sf

A sf object. The reference polygons.

seg_sf

A sf object. The segmentation polygons.

object

A segmetric object.

weight

Weights to summarize metrics. Accepts character options "ref", "seg", and "inter", that weights using reference, segment, and intersection areas, respectively. Also accepts a numeric vector of weights of the same length as input metrics giving the weights to be used.

na_rm

Should missing values (including NaN) be removed?

...

Additional parameters (Not implemented).

Value

  • sm_read(), sm_clear(): Return a segmetric object containing an empty list and an environment attribute to store the necessary datasets.

  • sm_is_empty(): Return a logical vector indicating if each computed metric is empty.

See also

Examples

# load sample datasets
data("sample_ref_sf", package = "segmetric")
data("sample_seg_sf", package = "segmetric")

# create segmetric object
m <- sm_read(ref_sf = sample_ref_sf, seg_sf = sample_seg_sf)

# plot geometries
plot(m)


# compute a metric
sm_compute(m, "AFI")
#> $AFI
#> [1] -0.004579302 -0.177491523 -0.065702379 -0.178723482  0.391009428
#> 

# summarize the metric using mean
sm_compute(m, "AFI") %>% summary()
#> [1] -0.007097452

# clear computed subsets
sm_clear(m)
#> list()