Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get network faces/azimuth between connected edges #178

Open
idshklein opened this issue Nov 7, 2021 · 1 comment
Open

Get network faces/azimuth between connected edges #178

idshklein opened this issue Nov 7, 2021 · 1 comment
Labels
feature 🎁 Request a new feature

Comments

@idshklein
Copy link

Lately I have learned about faces, a third component of a spatial planar network. Spatialite documentation expands here.
I was wondering how one would get the network faces using sfnetworks, but i do not know where to begin. assuming undirected network, one approach is to take every edge of the network and traversing to the edge which is the righetet/ leftest turn from the edge. However unfortunately, this function doesn't exist in sfnetworks.
I'm sure people here have better ideas on how to implement such a feature, which can greatly help in analyzing urban spaces.

@agila5
Copy link
Collaborator

agila5 commented Nov 7, 2021

Hi @idshklein and thank you very much for the reference. I briefly checked the link and I think that maybe we can simulate the same structure using the following approach. First, load usual packages

suppressPackageStartupMessages({
  library(sf)
  library(tidygraph)
  library(sfnetworks)
})

Then, load data and compute faces using the edges of the network and lwgeom::st_split

roxel = as_sfnetwork(roxel, directed = FALSE) %>% 
  convert(to_spatial_subdivision, .clean = TRUE) %>%
  st_transform(3857)
#> Warning: to_spatial_subdivision assumes attributes are constant over geometries
bbox = st_as_sfc(st_network_bbox(roxel)) %>% st_buffer(150)
faces <- lwgeom::st_split(bbox, st_geometry(roxel, "edges")) %>% 
  st_collection_extract("POLYGON")

Plot:

par(mar = rep(0, 4))
plot(faces, col = sf.colors(177, alpha = 0.5, categorical = TRUE))
plot(roxel, add = TRUE, cex = 0.7)

Created on 2021-11-07 by the reprex package (v2.0.1)

The light-green area should be f0 while all the other colours represent f1, f2 and so on. There are several limitations at the moment (i.e. no hierarchical structure among the faces, no realistic representation for f0, no way to automatically adjust those faces when modifying the network and so on). What do you think? Could you also suggest an application of these objects in urban spaces analysis? Might help with the implementation.

@luukvdmeer luukvdmeer added the feature 🎁 Request a new feature label Nov 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature 🎁 Request a new feature
Projects
None yet
Development

No branches or pull requests

3 participants