This plot function can be used to visualize bioregions based on a
bioregion.clusters object combined with a spatial object (sf or terra).
Usage
map_bioregions(
bioregionalization,
map,
partition_index = NULL,
map_as_output = FALSE,
plot = TRUE,
clusters = NULL,
geometry = NULL,
write_clusters = NULL,
...
)Arguments
- bioregionalization
A
bioregion.clustersobject.- map
A spatial object that can be handled by
sforterra. The first attribute or layer should correspond to the sites' ID (see Details).- partition_index
An
integer,character, orNULLspecifying whichbioregionalization's partition(s) to plot. By default (NULL), all partitions are plotted. If anintegeror vector ofintegersis provided, partition(s) are selected by column number(s) in thebioregionalizationdata.frame (starting from 1 after the ID column). If acharacteror vector ofcharacters, partition(s) are selected by name(s) matching column names inbioregionalization.- map_as_output
A
booleanindicating if thesfdata.frameobject used for the plot should be returned.- plot
A
booleanindicating if the plot should be drawn.- clusters
Deprecated. Use
bioregionalizationinstead. The formerbioregionalizationhas been replaced bypartition_index.- geometry
Deprecated. Use
mapinstead.- write_clusters
Deprecated. Use
map_as_outputinstead.- ...
Further arguments to be passed to
sf::plot().
Value
One or several maps of bioregions if plot = TRUE and the
sf data.frame object used for the plot if map_as_output = TRUE.
Details
The site IDs in bioregionalization and map should correspond. They must
have the same type (i.e., character if bioregionalization is a
bioregion.clusters object), and the sites in bioregionalization should be
included among the sites in map. If map is an sf or a SpatVector
(terra) object, it should contain an attribute table with the IDs in the
first column. If map is a SpatRaster (terra) object, it should contain
the IDs in the first layer.
If the bioregionalization object contains both types of nodes (sites and
species), only site will be mapped. The function automatically filters to
site nodes using the node_type attribute.
Colors: If the bioregionalization object contains colors (added via
bioregion_colors()), these colors will be automatically used for plotting.
Otherwise, the default sf color scheme will be applied.
See also
For more details illustrated with a practical example, see the vignette: https://biorgeo.github.io/bioregion/articles/a5_1_visualization.html.
Associated functions: bioregion_colors
Author
Maxime Lenormand (maxime.lenormand@inrae.fr)
Boris Leroy (leroy.boris@gmail.com)
Pierre Denelle (pierre.denelle@gmail.com)
Examples
data(fishmat)
data(fishsf)
net <- similarity(fishmat, metric = "Simpson")
clu <- netclu_greedy(net)
mapclu <- map_bioregions(clu,
map = fishsf,
map_as_output = TRUE,
plot = FALSE)
# With colors
clu_colored <- bioregion_colors(clu)
mapclu <- map_bioregions(clu_colored,
map = fishsf,
map_as_output = TRUE,
plot = FALSE)