View source: R/landscape_filter.R
landscape_filter | R Documentation |
Selects landscapes that meet certain pre-defined conditions in relation to its metrics from a 'MultiLandMetrics' object.
landscape_filter(
x,
conditions = list(rasterlayers = NULL, classes = NULL, radii = NULL, metric = NULL,
min_value = NULL, max_value = NULL),
output = "MLM"
)
x |
An object of class 'MultiLandMetrics' generated with |
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 |
This function allows to select 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, each element an inside list, as follows:
list(list(rasterlayers, class, radii, metric, minimum value, maximum value), list(rasterlayers, class, radii, metric, minimum value, maximum value), ...)
rasterlayers: the rasterlayers to be considered. If NA, all rasterlayers will be considered. If an extra rasterlayer must be specified, the string "ext" must precede the rasterlayer number (e.g. "ext1", "ext2").
class: the classes to be considered, as numbers or strings with the names of the classes. If NA, all classes of required rasterlayers will be considered. If NULL, the function will assume that the metric to be considered is a landscape-level metric. Take into account that metrics from extra calculations are considered as landscape-level metrics.
radii: the radii to be considered. If NA, all radii will be considered.
metrics: the name of the metric to be considered (as defined with its abbreviation by column "metric" in metrics_list()
).
Only one metric per condition can be defined. Metrics as extra calculations for extra rasterlayers must be
provided as "fun_" + the name of the function (e.g. "fun_mean").
minimum value: the minimum value that the metric must have in the filtered landscapes. If equal to -Inf, and a maximum value is defined, landscapes whose values in the defined metric are equal or lower to the maximum value will be retained.
maximum value: the maximum value that the metric must have in the filtered landscapes. If equal to Inf, and a minimum value is defined, landscapes whose values in the defined metric are equal or higher to the minimum value will be retained.
A plausible list of conditions could be the following:
list(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 rasterlayer 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 rasterlayer "ext1") between 70 and 80. Note that the slot for "class" is NULL, as extra rasterlayers do not hold classes.
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"
.
optimize_gradient()
# Filter landscapes that have between 20 and 30% of forest at a radius of 2000 m
# and output the data.frame with metrics values
otf_subset <- landscape_filter(otf_metrics,
conditions = list(list(NA, "Forest", 2000, "pland", 20, 30)),
output = "data")
# The same but returning a data.frame with information of the retained points
otf_subset_points <- landscape_filter(otf_metrics,
conditions = list(list(NA, "Forest", 2000, "pland", 20, 30)),
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.
otf_subset2 <- landscape_filter(otf_metrics,
conditions = list(list(NA, "Forest", 2000, "pland", 20, 30),
list(NA, "Crops", 2000, "pland", -Inf, 60)),
output = "data")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.