st_as_nodes | R Documentation |
Given geometry and a neighbor list, creates an sf
object to be used as nodes in an sfnetworks::sfnetwork()
. If the provided geometry is a polygon, sf::st_point_on_surface()
will be used to create the node point.
st_as_nodes(x, nb)
## S3 method for class 'sf'
st_as_nodes(x, nb)
## S3 method for class 'sfc'
st_as_nodes(x, nb)
x |
object of class |
nb |
a neighbor list. If |
st_as_node()
adds a row i
based on the attribute "region.id"
in the nb
object. If the nb
object is created with sfdep
, then the values will always be row indexes.
An object of class sf
with POINT
geometry.
if (requireNamespace("dplyr", quitly = TRUE)) {
library(magrittr)
guerry %>%
dplyr::transmute(nb = st_contiguity(geometry)) %>%
st_as_nodes(nb)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.