Learn R Programming

sfnetworks (version 0.3.1)

as_sfnetwork: Convert a foreign object to an sfnetwork object

Description

Convert a given object into an object of class sfnetwork. If an object can be read by as_tbl_graph and the nodes can be read by st_as_sf, it is automatically supported by sfnetworks.

Usage

as_sfnetwork(x, ...)

# S3 method for default as_sfnetwork(x, ...)

# S3 method for linnet as_sfnetwork(x, ...)

# S3 method for psp as_sfnetwork(x, ...)

# S3 method for sf as_sfnetwork(x, ...)

# S3 method for sfNetwork as_sfnetwork(x, ...)

# S3 method for sfnetwork as_sfnetwork(x, ...)

# S3 method for tbl_graph as_sfnetwork(x, ...)

Arguments

x

object to be converted into an sfnetwork object.

...

arguments passed on to the sfnetwork construction function.

Value

An object of class sfnetwork.

Examples

Run this code
# NOT RUN {
# Examples for linnet method
if (require(spatstat)) {
plot(simplenet, main = "spatstat input")
simplenet_as_sfnetwork = as_sfnetwork(simplenet)
plot(simplenet_as_sfnetwork, main = "sfnetworks output")
}
# Examples for psp method
if (require(spatstat)) {
set.seed(42)
test_psp = psp(runif(10), runif(10), runif(10), runif(10), window=owin())
plot(test_psp, main = "spatstat input")
test_psp_as_sfnetwork = as_sfnetwork(test_psp)
plot(test_psp_as_sfnetwork, main = "sfnetworks output")
}
# }

Run the code above in your browser using DataLab