Repository navigation
Description
Hello,
It would be great if momepy could include a function to calculate the Street-Network Disconnectedness index (SNDi) from this paper. The authors (Christopher Barrington-Leigh and Adam Millard-Ball) already have open-source code code in gitlab. However, it was not built to interface with an OSMnx graph.
The momepy function would take an OSMnx graph as an argument and return the SNDi. This supporting document explains the method to calculate the SNDi in detail. They provide this table gives to give an overview of all the different metrics
They then did a principal component analysis (PCA) of the whole world's street-network (GADM dataset) and decided on 13 distinct aggregate metrics for the SNDi:
- Nodal degree (negative)
- Fraction of dead-ends
- Log Circuity (0–0.5km)
- Log Circuity (0.5–1km)
- Log Circuity (1–1.5km)
- Log Circuity (1.5–2km)
- Log Circuity (2–2.5km)
- Log Circuity (2.5–3km)
- Fraction bridges (length)
- Fraction non-cycle (length)
- Fraction non-cycle (Number of edges)
- Fraction bridges (Number of edges)
- Log sinuosity
Pages 4-9 of the supporting document go into detail about how exactly the metrics are calculated. The authors first calculated each of these metrics for the whole-world and get a mean and standard deviation that is used to scale for smaller geographic regions. These are not in the documentation, but they are found in the code:
With these values, they came up with component loadings for the PCA:
Note that they only use PCA1 for the SNDI. So to calculate the PCA for a certain geographic region need:
- mean and standard deviation of the GADM dataset
- component loadings
- aggregate metric for certain region
The formula for PCA1 of a certain region is then:
With the PCA1 it is easy to calculate the SNDi as you just need to add 3
SNDi = PCA1 + 3
Please see PDF for below for reference:
Please let me know if something is unclear.
Also, from what I read in the supporting information, the nodal density is not actually used in the SNDi calculation. However, it is used for classifying cities if I read correctly. And it seems like the aggregate measures only take drivable streets (no bicycle, walking, or service edges). However, I am still a bit confused about this part (see page 36 of the supporting document) so I will need to do more reading.
Activity
martinfleis commentedon Jul 23, 2021
Hi,
this looks like a great addition. We would need to add individual functions computing circuity etc and then one using them all to compute SNDi.
I have no capacity to work on that, so if you'd like to try implementing some bits towards this goal, you're very welcome to do so. It is also possible that some of them are already implemented but I'd need to check their definitions.
amorfinv commentedon Aug 25, 2021
Hey @martinfleis,
I was hoping to get to this at some point but I am quite busy right now. Unsure when I will be able to do this. I will let you know whenever I start making some progress.
-Andres
amorfinv commentedon Sep 25, 2021
Started getting the ball rolling on this. I think it should be easy. Main challenge I am facing is figuring out how to merge edges that contain degree-2 nodes. I think this is what the authors do. I am currently able to do it for directed graphs so I hope it will be easy to apply to undirected graphs.
martinfleis commentedon Sep 25, 2021
You mean like we do in
momepy.remove_false_nodesor differently? http://docs.momepy.org/en/latest/generated/momepy.remove_false_nodes.htmlamorfinv commentedon Sep 26, 2021
I think that is exactly it!
amorfinv commentedon Sep 30, 2021
Hello,
So I pretty much finished all the metrics except circuity. For the sinuosity metric, I slightly updated
momepy.Linearityto include an aggregated measure.Is there anything in momepy that would work to calculate circuity? There is
osmnx.stats.circuity_avin osmnx that I can use for inspiration.-Andres
update:
I found these distance matrix functions that make things into numpy arrays. So I think I will just use this.
shortest path distance matrix
nx.floyd_warshall_numpyeuclidean distance matrix
libpysal.cg.distance_matrixmartinfleis commentedon Sep 30, 2021
Hi, great!
We could adapt what we have in
Linearityto get circuity I guess but if you have NumPy version already that may be faster :).amorfinv commentedon Oct 1, 2021
finished a version 1...however results are quite off haha..so trying to see what I did wrong
martinfleis commentedon Oct 1, 2021
Feel free to push it as a draft PR, we can have a look as well.