SPAtial GrapHs: nETworks, Topology, & Inference (spaghetti)
Description:
- An open-source Python library for the analysis of network-based spatial data. Originating from the network module in PySAL (Python Spatial Analysis Library), it is under active development for the inclusion of newly proposed methods for building graph-theoretic networks and the analysis of network events.
Resources:
- [GitHub] https://github.com/pysal/spaghetti
- [Examples] https://github.com/pysal/spaghetti/tree/main/notebooks
- [Websites] http://pysal.org/spaghetti/
Example 1
Section titled “Example 1”Get the network component Labels
import geopandasimport libpysalfrom libpysal import examplesfrom libpysal.cg import Point, Chainimport matplotlibimport matplotlib_scalebarfrom matplotlib_scalebar.scalebar import ScaleBarimport spaghetti
plus1 = [ Chain([Point([1, 2]), Point([0, 2])]), Chain([Point([1, 2]), Point([1, 1])]), Chain([Point([1, 2]), Point([1, 3])]),]plus2 = [ Chain([Point([2, 1]), Point([2, 0])]), Chain([Point([2, 1]), Point([3, 1])]), Chain([Point([2, 1]), Point([2, 2])]),]lines = plus1 + plus2ntw = spaghetti.Network(in_data=lines)
ntw.network_component_labelsganymede is made by Eugo