Analyzing geospatial networks in R with sfnetworks
65th Annual Conference of the South African Statistical Association
About
Date
19 November 2024 | 08h30 - 13h00
Abstract
Geospatial networks are graphs embedded in geographical space. That means that both the nodes and edges in the graph can be represented as geographic features (e.g. points and lines) with a location somewhere on or near the surface of the earth. They play an important role in many different domains, ranging from transportation planning and logistics to ecology and epidemiology. The structure and characteristics of geospatial networks go beyond standard graph topology, and therefore it is crucial to explicitly take space into account when analyzing them. The R package sfnetworks is created to facilitate such an integrated workflow. It combines the forces of two popular R packages, sf for spatial data science and tidygraph for standard graph analysis, and extends them with functionalities that are specific to geospatial network analysis, such as geographic shortest path calculations, geospatial network cleaning, and topology modification. It also facilitates smooth integration with packages for statistical analysis on spatial linear networks, and is designed to seamlessly fit into tidy data wrangling workflows. This workshop provides an introduction to the sfnetworks package for geospatial network analysis. We will start with simple examples on abstract dummy networks, and gradually move towards the analysis of real-world networks that we extract from OpenStreetMap. We will prepare several analytical tasks to solve, of varying difficulty. If you are already working with geospatial networks, you are also encouraged to bring your own use-cases.
Schedule
Time | Description |
---|---|
8h30 - 8h45 | Welcome + set-up |
8h45 - 9h45 | Intro to sfnetworks |
9h45 - 10h30 | Hands-on preparation |
10h30 - 11h00 | Morning tea |
11h00 - 12h30 | Hands-on tasks |
12h30 - 13h00 | Present your work + wrap-up |
Hands-on setting
For this workshop, we have materials to showcase sfnetworks
and for you to work with the package on different tasks. We also encourage you to bring your own data and use cases to test sfnetworks
capabilities for your workflows.
To follow along and code for yourself you have two options:
- Work locally on your own R and RStudio set-up
- Use GitHub Codespaces
If you did not manage to prepare your set-up in advance for the workshop, we recommend to use GitHub Codespaces.
1. Working locally
R and RStudio installation
A working installation of:
- R (follow CRAN recommendations for your set-up).
- RStudio (>= 2024.04.x with Quarto) see here.
R packages
Please run these commands inside the R console:
# Install the remotes package from CRAN Repo
install.packages("remotes")
# Install workshop and its dependencies
::install_github("luukvdmeer/sfnetworks-workshop") remotes
Clone the workshop repository
To obtain the workshop materials you can clone the repository to run the Quarto documents interactively.
2. Using GitHub Codespaces
Make sure you have a GitHub account
To use Codespaces you will need a GitHub account. You can sign-up here.
Create your codespace
Go to the workshop GitHub repository and click on the green button called “Code”, go to the “Codespaces” tab and click on “Create codespace on main”.
A new tab will open where your Codespace will start setting-up. The process takes about 10 minutes. If you can do this before the workshop, you will save some time. However, we will go through this instructions at the start of the workshop to make sure the set-up is all set by the time we need to start coding!
Launch RStudio
Once the set-up is done, you can go to ports and launch the RStudio application in port 8787 by clicking on the browser button.
If this does not work, you might need to reload the codespace page.
You will get a pop-up window to type your username/password
. You can use rstudio/rstudio
for that.
Now you should be in an RStudio server, congrats!
The only thing missing is having the workshop files on our “Files” pane. For this, click on the ...
or “Go to directory” button on the files pane (shown with the red-arrow below). On the pop-up window type /workspaces
and Enter.
You should now be able to see the sfnetorks-workshop
directory. Click on it and you will have a cloned access of the workshop materials.
And you are all set!
Codespace management
Your Codespace should be available to you every time you go to the workshop repository. GitHub will auto-delete your Codespace after a certain amount of time if you have not used it. This is meant to free up your Codespace storage.
If you have set-up the Codespace some days before the workshop, it should stay there but if you want to control when the Codespace is deleted, you can do so with the dropdown (...
) next to your codespace and de-selecting the “Auto-delete codespace” option.