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

centrality measures #1

Open
temospena opened this issue Apr 11, 2023 · 13 comments
Open

centrality measures #1

temospena opened this issue Apr 11, 2023 · 13 comments

Comments

@temospena
Copy link
Member

Using sfnetworks, centrality and betweeness produces weired results

image
Maybe check with igraph, of use more road links from OSM

@szhorvat
Copy link

szhorvat commented Apr 11, 2023

Note that closeness centrality is not meaningful for disconnected graphs.

I do not know your dataset, but the presence of a few vertices with very high closeness suggests that these exist in tiny connected components, thus they are "close" to all other vertices which are reachable from them. I'd check if the network is connected. If not, closeness is not a useful metric.

@temospena
Copy link
Member Author

Thanks @szhorvat for the heads-up!

I added more OSM highway tags, did some network cleaning and topology validation in Grass, and the results really improved.
Well, at least are not almost all zero (although x10^-9)

image

We'll see if this is enough for now...
bcd22ec

@temospena
Copy link
Member Author

I think that we should remove the unnecessary nodes from the OSM. This will prob affect the centrality measures, but provides a more realistic result.

image

See https://geoffboeing.com/2016/11/osmnx-python-street-networks/
https://github.com/anerv/NERDS_osmnx
and

Note that the simplification function only simplifies and merges edges that have identical values for important attributes such as geometry type, bicycle direction, and protection level.
image
Non-simplified network (left) and simplified network (right).

@temospena temospena reopened this Jun 28, 2023
@temospena
Copy link
Member Author

@temospena
Copy link
Member Author

@Robinlovelace would you know if this is possible to do in R or with R/qgisprocess ?

https://github.com/gboeing/osmnx/blob/4f23b37b9a21c0fb513e58171d759bbd8b87ce60/osmnx/simplify.py#L207

My first thought would be to have a OSMX pluggin in QGIS and do from there (with qgisprocess connection).
But there isn't.
I thing that grass has not such option to simplify topology by removing unnecessary nodes.

Have you faced this issue before?
Thank you!

@Robinlovelace
Copy link

Hi @temospena interesting and important problem! Yes I think it can be done in R, including with sfnetworks but have never done it myself. One link that may be helpful (not in R) is this: https://github.com/anisotropi4/parenx Python package.

@temospena
Copy link
Member Author

temospena commented Feb 16, 2024

  • include code from code/centrality.R regarding "Remove duplicate nodes" (uses sfnetworks) in code/centrality_qgis.R and assess the differences in centrality measures.

@temospena
Copy link
Member Author

@temospena
Copy link
Member Author

temospena commented Feb 16, 2024

I managed to clean them with

net = as_sfnetwork(road_network_clean)
smoothed = convert(net, to_spatial_smooth)

nodes_smoothed = smoothed %>%
  activate(nodes) %>%
  as_tibble() |> 
  st_as_sf(coords = c('X', 'Y'))

After v.clean grass process:
image

Clean (smoothed):
image

temospena added a commit that referenced this issue Feb 16, 2024
#1
still need to integrate in functions
@Robinlovelace
Copy link

Fantastic, great to see and thanks for sharing @temospena. Cc @juanfonsecaLS1 who's doing some network processing as a preparatory step on the pathway towards minor traffic estimation.

@juanfonsecaLS1
Copy link

This is very interesting work @temospena. I have been using dodgr for a similar analysis, the contracted dodgr graph simplifies the geometries and exclude redundant nodes.

Also, are you normalising the betweenness centrality? There is a useful publication on this here

temospena added a commit that referenced this issue Feb 22, 2024
#1
added option to re_clean osm if needed
@temospena
Copy link
Member Author

Thanks @juanfonsecaLS1 ! This is indeed a very interesting paper.
Looking at repo here: https://github.com/christian-werner/spatial-centrality-pub

So, maybe I am using to many different packages to achieve the same purpose 🤔

What I am doing is:

  • Get OSM highways
  • Remove the edges from the disconnected groups
  • Using grass7:v.clean (with break, snap, rmdangle, rmdupl, bpol)
  • converting to sfnetwork and using spatial_smooth to remove the redundant nodes
  • using grass7:v.net.centrality to estimate degree, closeness and betweness for each node (it provided better results than sfnetworks) - I would say that this uses betweeness centrality instead of spatial betweness centrality, but not sure
  • get the mean of these values in a grid

What we are interested is in a mean of re-scaled centrality measures in a grid.
Here is the paper from @valenca13 that we are trying to reproduce and replicate for any city.

So, using dodgr would simplify the process?

@Robinlovelace
Copy link

This is awesome Rosa, loads of great detail. I discussed it with Juan yesterday, looking forward to seeing what he comes up with that's related to this stuff (to estimate motor traffic in our case).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants