Spaghetti is 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.
An example of a network's minimum spanning tree:
The following are a selection of some examples that can be launched individually as interactive binders from the links on their respective pages. Additional examples can be found in the Tutorials section of the documentation. See the pysal/notebooks
project for a jupyter-book
version of this repository.
Python >= 3.10 is tested for support by spaghetti
. Please make sure that you are operating in a Python >= 3.10 environment.
Installing with conda
via conda-forge
(highly recommended)
To install spaghetti
and all its dependencies, we recommend using the conda
manager, specifically with the conda-forge
channel. This can be obtained by installing the Anaconda Distribution
(a free Python distribution for data science), or through miniconda
(minimal distribution only containing Python and the conda package manager).
Using conda
, spaghetti
can be installed as follows:
$ conda config --set channel_priority strict
$ conda install --channel conda-forge spaghetti
Also, geopandas
provides a nice example to create a fresh environment for working with spatial data.
Installing with PyPI
$ pip install spaghetti
or download the source distribution (.tar.gz
) and decompress it to your selected destination. Open a command shell and navigate to the decompressed folder.
$ pip install .
Warning
When installing via pip
, you have to ensure that the required dependencies for spaghetti
are installed on your operating system. Details on how to install these packages are linked below. Using conda
(above) avoids having to install the dependencies separately.
Install the most current development version of spaghetti
by running:
$ pip install git+https://github.com/pysal/spaghetti
spaghetti
was
created and has evolved in line with the Python Spatial Analysis Library ecosystem for
the specific purpose of utilizing the functionality of spatial weights in
libpysal
for generating network segment contiguity objects.
The PySAL project was started in the mid-2000s when installation was difficult to maintain.
Due to the non-triviality of relying on dependencies to secondary packages, a conscious
decision was made to limit dependencies and build native PySAL data structures in cases
where at all possible. Therefore, the original pysal.network
submodule was developed to
address the need for integrating support for network data structures with PySAL weights
data structures, with the target audience being spatial data scientists and anyone
interested in investigating network-centric phenomena within PySAL. Owing to the
co-development of network functionality found within spaghetti
and the evolution of
the wider PySAL ecosystem, today, the package provides specialized network functionality
that easily integrates with the rest of PySAL. This allows users of spaghetti
’s network
functionality to access spatial analysis functionality that complements network analysis,
such as spatial statistical tools with esda
and integration with core components of
libpysal
: libpysal.weights
(mentioned above),
libpysal.cg
(computational geometry and data structures),
libpysal.io
(input-output), and libpysal.examples
(built-in example data).
PySAL-spaghetti is under active development and contributors are welcome.
If you have any suggestions, feature requests, or bug reports, please open new issues on GitHub. To submit patches, please review PySAL's documentation for developers, the PySAL development guidelines, the spaghetti
contributing guidelines before opening a pull request. Once your changes get merged, you’ll automatically be added to the Contributors List.
If you are having issues, please create an issue, start a discussion, or talk to us in PySAL's Discord channel. All questions, comments, & discussions should happen in a public forum, where possible. Private messages and emails will not be answered in a substantive manner.
As a PySAL-federated project, spaghetti
follows the Code of Conduct under the PySAL governance model.
The project is licensed under the BSD 3-Clause license.
If you use PySAL-spaghetti in a scientific publication, we would appreciate using the following citations:
@article{Gaboardi2021,
doi = {10.21105/joss.02826},
url = {https://doi.org/10.21105/joss.02826},
year = {2021},
publisher = {The Open Journal},
volume = {6},
number = {62},
pages = {2826},
author = {James D. Gaboardi and Sergio Rey and Stefanie Lumnitz},
title = {spaghetti: spatial network analysis in PySAL},
journal = {Journal of Open Source Software}
}
@misc{Gaboardi2018,
author = {Gaboardi, James D. and Laura, Jay and Rey, Sergio and
Wolf, Levi John and Folch, David C. and Kang, Wei and
Stephens, Philip and Schmidt, Charles},
month = {oct},
year = {2018},
title = {pysal/spaghetti},
url = {https://github.com/pysal/spaghetti},
doi = {10.5281/zenodo.1343650},
keywords = {graph-theory,network-analysis,python,spatial-networks,topology}
}
This project is/was partially funded through:
Atlanta Research Data Center: A Polygon-Based Approach to Spatial Network Allocation
National Science Foundation Award #1825768: National Historical Geographic Information System