skillfed

spaghetti

Analysis of Network-constrained Spatial Data

spaghetti v1.7.6 101.1K downloads/30d#12,962 on PyPI284
Permissive license BSD 3-Clause Active released

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 spaghetti

uv

uv add spaghetti

poetry

poetry add spaghetti

Installing 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

Intended Audience :: Science/ResearchLicense :: OSI Approved :: BSD LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3Topic :: Scientific/Engineering :: GIS

Tags

spatial network analysisgraph-based geographic datanetwork topology spatialshortest path networksspatial graph algorithmsnetwork-constrained analysisgeographic network events
spatial-networksgraph-analysisgis

More GIS packages