gdf_to_nx only uses first and last points of geometry (LineStrings) #500
Replies: 2 comments 6 replies
-
No, it should not. What we're doing here is transforming a representation of a network where each LineString encodes a portion of, for example, road network between two logical nodes, i.e. junctions. This portion may be straight or super curvy but it is still one portion (I am intentionally avoiding the word segment), which shall be represented in a graph as a single edge between two nodes. The geometry itself is stored as an edge attribute so it is not lost. Your proposal creates a different graph. One that does not encode logical portions of a network into a graph but one that encodes the way someone has drawn the geometry. You can have a curve composed of 10 segments of LineString or 100 or even 1000 if you want to have a really smooth shape. Each of those encodes the same part of a road network, so each should be a single edge between two nodes. While in your case, you would end up with vastly different graphs encoding different relationships between physical elements. Moreover, you would have a ton of nodes of a degree 2 which are often considered superfluous (but that depends on the type of a graph of course). I can imagine that a graph you seek may have some use cases but those are unlikely within the scope of momepy. Happy to hear the use case and why you think what we do is wrong in there, though. |
Beta Was this translation helpful? Give feedback.
-
I wonder how the |
Beta Was this translation helpful? Give feedback.
-
LineStrings
can contain more than two points but the_generate_primal
method used ingdf_to_nx
only parses the first and last points:momepy/momepy/utils.py
Lines 75 to 77 in 2fda11e
Instead,
_generate_primal
should loop throughrow.geometry.coords[0:-1]
andgraph.add_edge
for each value, e.g.Beta Was this translation helpful? Give feedback.
All reactions