Learn R Programming

⚠️There's a newer version (0.6.5) of this package.Take me there.

Tidy Geospatial Networks in R

sfnetworks is an R package for analysis of geospatial networks. It connects the functionalities of the tidygraph package for network analysis and the sf package for spatial data science.

Background

Thanks to active developer and user communities, R is becoming an increasingly popular language for interactive geospatial data analysis. A large step forward was the release of the sf package, which provides classes and functions to represent and manipulate spatial vector data. Unlike its predecessors, sf is compatible with the popular data science oriented packages that form the tidyverse, most notably the data manipulation toolbox dplyr, and more generally with the concept of tidy data.

R is also well-suited for network analysis, thanks to the R interface of the igraph library. The tidygraph package extends igraph into the domain of the tidyverse, enabling compatibility with dplyr by treating a graph as a collection of two tidy data frames describing respectively the nodes and edges.

Given the strength of R in spatial and network analysis, one would expect it to be an ideal language for analysis of geospatial networks. Geospatial networks are simultaneously graph and spatial objects, with nodes and edges embedded in geographic space. Well known examples include transport networks, river basins, power grids, ecological networks and geolocated social networks.

Although several R packages exist that address geospatial networks, they often focus on a specific application within the broader domain of geospatial network analysis, or complicate tidyverse compatibility. At present, no general purpose, tidyverse compatible classes exist for geospatial network data, representing a gap in R's spatial and network analysis ecosystems (see the gRaphical Models and Spatial task views). sfnetworks is created to fill this gap, and form a connecting edge between the two worlds.

The core of the package is a data structure that can be provided as input to both graph analytical functions of tidygraph and to spatial analytical functions of sf, without the need for conversion. On top of that, it contains a set of spatial network specific functions that can be used alongside the offer of the two 'parent packages'.

Installation

The sfnetworks package is still in very active development, Therefore, the package is also not on CRAN yet. Install it directly from GitHub using the remotes package in R.

Install the more stable master branch with:

remotes::install_github("luukvdmeer/sfnetworks")

Install the develop branch, where most of the development takes place and where PRs should be directed, as follows:

remotes::install_github("luukvdmeer/sfnetworks", ref = "develop")

Originally, sfnetworks was created as a homework assignment for an R course. Some people actually started using that version of the package in their work. Note that the new package is completely different! If you still want to install the original version, use:

remotes::install_github("luukvdmeer/sfnetworks@v0.1")

Usage

The main goal of sfnetworks is to connect the tidygraph package for network analysis and the sf package for spatial data science. To make the most out of it, it is recommended to make yourself familiar with these two 'parent packages' if you don't know them yet.

There are currently five vignettes that guide you through the functionalities of sfnetworks:

Contribution

We look very much forward to contributions to the package. See the contributing guide for further details.

This project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

Acknowledgment

This project gratefully acknowledges financial support from the

Copy Link

Version

Install

install.packages('sfnetworks')

Monthly Downloads

2,253

Version

0.4.1

License

Apache License (>= 2) | file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Lucas van der Meer

Last Published

December 6th, 2024

Functions in sfnetworks (0.4.1)

roxel

Road network of M<U+00FC>nster Roxel
as_tibble

Extract the active element of a sfnetwork as spatial tibble
as.linnet

Convert a sfnetwork into a linnet
plot.sfnetwork

Plot sfnetwork geometries
is.sfnetwork

Check if an object is a sfnetwork
sf

sf methods for sfnetworks
as_sfnetwork

Convert a foreign object to a sfnetwork
autoplot

Plot sfnetwork geometries with ggplot2
reexports

Objects exported from other packages
node_coordinates

Query node coordinates
spatial_morphers

Spatial morphers for sfnetworks
spatial_node_predicates

Query nodes with spatial predicates
st_network_blend

Blend geospatial points into a spatial network
st_network_bbox

Get the bounding box of a spatial network
st_network_paths

Paths between points in geographical space
sfnetwork

Create a sfnetwork
sf_attr

Query sf attributes from the active element of a sfnetwork
st_network_cost

Compute a cost matrix of a spatial network
st_network_join

Join two spatial networks based on equality of node geometries
spatial_edge_predicates

Query edges with spatial predicates
spatial_edge_measures

Query spatial edge measures