-
Notifications
You must be signed in to change notification settings - Fork 71
Refactor: spaghetti v2.0
eli knaap edited this page Aug 9, 2021
·
6 revisions
The pysal
submodule spaghetti
originated from network
before pandas
had been considered as a dependency in pysal
and prior to the reorganization that transformed the project from a single monolithic package into a group of confederated submodules linked with libpysal
. Through the new structure submodule maintainers are given the freedom to add external dependencies, a practice that was previously discouraged.
-
osmnx
— OpenStreetMap +networkx
-
pandana
—pandas
for network analysis -
snkit
— a spatial networks toolkit (#368) - others? feel free to add!
- maintain support for native
pysal
objects/geometries while including the option for serious performance improvements made possible through external libraries- Improved support for PySAL geometries in
v1.4.1
- Improved support for PySAL geometries in
- simplify and generally refactor code base
- strengthen ties to
libpysal
where possible to ensure DRY programming
- store all network segments (one per record) (pandas.DataFrame)
- network segment endpoints as graph nodes
- do not record degree-2 vertices (check Okabe naming)
- network retains original spatial structure (
libpysal.cg.Chain
/shapely.geometry.LineString
) - graph expresses only
- relationship between nodes; and
- distance between nodes (sure to non-euclidean nature of network (segments?)
- network retains original spatial structure (
- snapping should be available to
libpysal.cg.Chain
- snapping can be a lookup by nearest endpoint (dissertation code:
snap_to_nearest
- quadrat search for intersections (dissertation code:
get_intersections
) - must include node insertion for snapping/network voronoi
- shortest path calculation is MUCH faster with dijkstra from points within a network than from nearest snapped
- this will also allow for multisource dijkstra, which in turn with allow for network voronoi diagrams
- ek: the data structure you describe above is basically what pandana uses, and it also implements network node snapping and shortest pathfinding via contraction hierarchies rather than dijkstra (which is what give it such outstanding performance). Might we want to just build on those structures? Once 167 is merged, it should also make the library more flexible to work with
-
Giving this another push see issue here
-
See notes from PySAL meeting here
-
- rely on
shapely
(pygeos
) geometries through GeoPandas objects- spatial queries
.sindex.nearest()
(currently being worked out?)
- spatial queries
- represent networks as two
GeoDataFrame
objects (nodes - include components of...
-
momepy
-->networkx
-
networkx
-
snkit
- clean implementation (see here)
-
pyrosm
and/orosmnx
- fetching data when not provided? -- probably best to leave this separate?
-
pandana
- already integrated with
segregation
.
- already integrated with
-
- rely on
-
- Associating observations with the network is probably the important aspect of
spaghetti
- The current implementation treats observations (
PointPattern
) separately than networks nodes. Since the observations are not network nodes, we can't use the traditional implementation of the dijkstra, which causes a HUGE time and memory leak.
- The current implementation treats observations (
- Licensing
- Associating observations with the network is probably the important aspect of
-
- Data Input
- streets/paths (lines) geodataframe or path {.shp, .gpkg+layer, etc.}
- observations (points) geodataframe or path {.shp, .gpkg+layer, etc.}
- Preprocess
- remove non-articulation points from lines data (degree-2 nodes) (see
momepy
here andsnkit
here) - allocate observations to line segments...
- actual vs. abstract
- if observations are actual (fire station) generate single connector to nearest location along nearest segment
- if observations are abstract (census block centroid) generate n connector(s) to nearest n endpoints
- In both actual and abstract scenarios the observations become nodes in the network and connectors become edges. This allows for using dijkstra to create cost matrices between only observations in the network (which is currently not the case in
spaghetti
), and will allow for multi-source dijkstra (see 374) and network Voronoi diagrams (see 292) - This also means the degree-2 nodes can exist in the network/graph when the nearest location along the network is a degree-1 node (where the connector edge has to be retained and labeled a special network segment).
- actual vs. abstract
- remove non-articulation points from lines data (degree-2 nodes) (see
- Create Network Topology
- store as an object with
nodes
andedges
attributes as geodataframes? - contiguity from PySAL W?
- ...
- store as an object with
- Generate Observation-Observation cost matrices
- Perform Network Analysis
- etc...
- Data Input