metrics_filter {multilandr}R Documentation

Filters metrics

Description

Selects landscapes that meet certain pre-defined conditions in relation to its metrics from a 'MultiLandMetrics' object.

Usage

metrics_filter(x, conditions, output = "MLM")

Arguments

x

An object of class 'MultiLandMetrics' generated with mland_metrics().

conditions

List. Conditions to be met by the landscapes. See Details.

output

One of the following: "MLM" to return an updated version of the 'MultiLandMetrics' object provided in x (default), "spatial" to return a 'SpatVector' with the points of the selected landscapes, "data" to return a data.frame with the metric values information or "coords" to return a data.frame with geographical information of the filtered points.

Details

Selects landscapes that meet certain conditions in relation to the values of their landscape metrics. The function will retain those points associated with the landscapes that meet all the defined conditions at the same time. Conditions must be provided through a list, for which the helper function conditions() is available:

 conditions(list(rasterlayers, class, radii, metric, minimum value, maximum value),
            list(rasterlayers, class, radii, metric, minimum value, maximum value),
            ...)

A plausible list of conditions could be the following:

 conditions(list(1, 2, 1000, "pland", 20, 30),
            list(1, 4, 1000, "np", 1, 15),
            list("ext1", NULL, 1000, "fun_mean", 70, 80))

And it would indicate that landscapes of radius equal to 1000 m should present values of "pland" (percentage of the landscape) for class 2 from raster layer 1, between 20 and 30%. At the same time, landscapes of radius equal to 1000 m should present values of "np" (number of patches) for class 4 from rasterlayer 1, between 1 and 15 patches. Finally, all selected landscapes of radius equal to 1000 m should present values for "fun_mean" (applied to extra raster layer "ext1") between 70 and 80. Note that the slot for "class" is NULL, as extra raster layers do not hold classes.

Value

A 'MultiLandMetrics' if output = "MLM", a 'SpatVector' if output = "spatial", a data.frame if output = "data" or a data.frame with geographical information of the points if output = "coords".

See Also

metrics_gradient()

Examples

# Filter landscapes that have between 20 and 30% of forest at a radius of 2000 m
# and output the data.frame with metrics values
conds <- conditions(list(NA, "Forest", 2000, "pland", 20, 30))
otf_subset <- metrics_filter(otf_metrics,
                             conditions = conds,
                             output = "data")

# The same but returning a data.frame with information of the retained points
conds <- conditions(list(NA, "Forest", 2000, "pland", 20, 30))
otf_subset_points <- metrics_filter(otf_metrics,
                                    conditions = conds,
                                    output = "coords")

# Filter landscapes that have between 20 and 30% of forest at a radius of 2000 m
# and a maximum of 60% of Crops.
conds <- conditions(list(NA, "Forest", 2000, "pland", 20, 30),
                    list(NA, "Crops", 2000, "pland", -Inf, 60))
otf_subset2 <- metrics_filter(otf_metrics,
                              conditions = conds,
                              output = "data")

[Package multilandr version 1.0.0 Index]