spaghetti
Analysis of Network-constrained Spatial Data
What it is and what it does
Spaghetti is a Python library for analyzing spatial networks—geographic data structured as graphs of connected line segments and nodes. It originated from PySAL's network module and provides tools for building networks from geographic features, computing network topology, finding shortest paths, and analyzing network events within a spatial context. The library integrates tightly with the PySAL ecosystem, allowing users to combine network analysis with spatial statistics (via esda), spatial weights (via libpysal), and geospatial operations (via geopandas and shapely).
The package is designed for spatial data scientists and researchers studying network-centric phenomena—transportation networks, utility grids, social networks with geographic constraints, and similar structures where both topology and location matter. It depends on eight runtime packages including numpy, scipy, geopandas, and rtree, making it part of a larger geospatial Python stack rather than a standalone tool. Installation via conda-forge is recommended to avoid manual system dependency setup.
Use it for:
- Analyze transportation networks to find shortest routes or identify bottlenecks in road or transit systems.
- Study utility infrastructure (power grids, water pipes) as spatial graphs to detect network fragmentation.
- Compute network-constrained distances for spatial statistical tests that account for connectivity.
- Build minimum spanning trees from geographic point or line data for network design problems.
- Integrate network topology with spatial weights for neighborhood analysis along network edges.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Spaghetti analyzes network-based spatial data by building graph-theoretic networks from geographic features and computing network events, topology, and spatial inference on them.
Yes, if you work with geographic networks and need graph-theoretic analysis integrated with spatial statistics. The package is actively maintained, has no known vulnerabilities, and fits naturally into the PySAL ecosystem. Install via conda-forge to avoid dependency friction. Not necessary if you only need basic graph algorithms without spatial context.
Install
spaghetti on PyPI
pip
pip install spaghettiuv
uv add spaghettipoetry
poetry add spaghettiInstalling spaghetti
Before you install
Low friction: pure Python wheel with no compiled dependencies beyond the spatial stack (geopandas, shapely, rtree, scipy). Active maintenance as of July 2026 with regular releases since 2018.
License in practice
BSD 3-Clause is permissive; you can use, modify, and distribute spaghetti freely in commercial and private projects provided you retain the license notice.
Quickstart
import spaghetti
import geopandas as gpd
# Load a GeoDataFrame of network geometries
net = spaghetti.Network(gdf.geometry)
# Compute shortest path or analyze network topology
path = net.shortest_path(source, target)
Requires Python >= 3.10 and libspatialindex system library (installed automatically via conda, manual install required for pip on some systems).
Verify before relying
- Whether the package supports dynamic network updates or only static graph construction.
- Performance characteristics on large networks (node/edge count thresholds).
- Availability of specialized algorithms beyond shortest path and spanning tree.
Package facts
| License | BSD 3-Clause (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 8 — esda, geopandas, libpysal, numpy, pandas, rtree, scipy, shapely |
| Maintenance | actively maintained — 784 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 101,121/month — #12,962 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: spaghetti-1.7.6-py3-none-any.whl
Keywords: spatial statistics, networks, graphs
Tags
More GIS packages
Shapely provides Python tools for creating,…
permissive · top 1,000 on PyPI
pyprojpyproj provides a Python interface to PROJ,…
permissive · top 1,000 on PyPI
geopandasGeoPandas extends pandas DataFrames to handle…
permissive · top 1,000 on PyPI
geopygeopy is a Python client for geocoding and…
permissive · top 5,000 on PyPI
pyogrioPyogrio provides fast, bulk-oriented read and…
permissive · top 5,000 on PyPI
h3h3 provides Python bindings to Uber's H3…
permissive · top 5,000 on PyPI
esdaesda computes global and local spatial…
permissive · top 15,000 on PyPI
spoptSpopt solves spatial optimization problems…
permissive · top 15,000 on PyPI
giddyGiddy provides methods for exploratory…
permissive · top 15,000 on PyPI
pysalPySAL is a meta-package that bundles 29 spatial…
permissive · top 15,000 on PyPI
inequalityInequality provides methods for measuring…
permissive · top 15,000 on PyPI
libpysallibpysal provides core spatial analysis…
permissive · top 15,000 on PyPI
rtreeRtree wraps libspatialindex to provide spatial…
permissive · top 5,000 on PyPI
pointpatsPointpats provides statistical methods for…
permissive · top 15,000 on PyPI
ripserRipser computes persistent homology and…
permissive · top 15,000 on PyPI
scikit-networkscikit-network provides graph algorithms and…
permissive · top 5,000 on PyPI