tidygraph_methods: tidygraph methods for sfnetworks

tidygraph_methodsR Documentation

tidygraph methods for sfnetworks

Description

Normally tidygraph functions should work out of the box on sfnetwork objects, but in some cases special treatment is needed especially for the geometry column, requiring a specific method.

Usage

## S3 method for class 'sfnetwork'
as_tbl_graph(x, ...)

## S3 method for class 'sfnetwork'
reroute(.data, ...)

## S3 method for class 'sfnetwork'
morph(.data, ...)

## S3 method for class 'morphed_sfnetwork'
unmorph(.data, ...)

Arguments

x

An object of class sfnetwork.

...

Arguments passed on the corresponding tidygraph function.

.data

An object of class sfnetwork.

Details

See the tidygraph documentation. The following methods have a special behavior:

  • reroute: To preserve the valid spatial network structure, this method will replace the boundaries of edge geometries by the location of the node those edges are rerouted to or from. Note that when the goal is to reverse edges in a spatial network, reroute will not simply reverse the edge geometries. In that case it is recommended to use the sfnetwork method for st_reverse instead.

  • morph: This method checks if the morphed network still has spatially embedded nodes. In that case a morphed_sfnetwork is returned. If not, a morphed_tbl_graph is returned instead.

  • unmorph: This method makes sure the geometry list column is correctly handled during the unmorphing process.

Value

The method for as_tbl_graph returns an object of class tbl_graph. The method for morph returns a morphed_sfnetwork if the morphed network is still spatial, and a morphed_tbl_graph otherwise. All other methods return an object of class sfnetwork.


luukvdmeer/sfnetworks documentation built on Nov. 21, 2024, 4:54 a.m.