| linestrings_from_graph | R Documentation |
Convert a graph data frame with node coordinates to an sf object with LINESTRING geometries.
linestrings_from_graph(graph_df, crs = 4326)
graph_df |
A data frame representing a graph with columns:
|
crs |
Numeric or character (default: 4326). Coordinate reference system to assign to the output sf object. |
This function is the inverse operation of linestrings_to_graph. It:
Creates LINESTRING geometries from node coordinates (FX, FY, TX, TY)
Removes the coordinate columns from the output
Preserves all other columns from the input graph data frame
Returns an sf object suitable for spatial operations and visualization
An sf data frame with LINESTRING geometry, containing all columns from
graph_df except FX, FY, TX, and TY. Each row
represents an edge as a LINESTRING connecting the from-node (FX, FY)
to the to-node (TX, TY).
linestrings_to_graph flownet-package
library(flownet)
library(sf)
# Convert segments data frame to sf LINESTRING object
segments_sf <- linestrings_from_graph(africa_segments)
class(segments_sf)
head(segments_sf)
# Plot segments colored by route importance
plot(segments_sf["passes"])
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.