Skip to main content

Documentation Status Build License PyPI version DOI Poster Conda Forge version

snkit - a spatial networks toolkit

/ˈsnɪkɪt/ – sounds like snicket (noun, Northern English) A narrow passage between houses; an alleyway.

Why use snkit?

snkit helps tidy spatial network data.

Say you have some edges and nodes (lines and points, connections and vertices). None of them are quite connected, and there's no explicit data to define which node is at the end of which edge, or which edges are connected.

For example:

Unconnected network

snkit has methods to:

  • add endpoints to each edge
  • connect nodes to nearest edges
  • split edges at connecting points
  • create node and edge ids, and add from_id and to_id to each edge

Spatial network

The output of a snkit data cleaning process might look something like this:

Connected network

Nodes

geometry id other attributes...
POINT (0.03 0.04) node_0 ...
POINT (0.03 0.03) node_1 ...
POINT (0.02 0.03) node_2 ...

Edges

geometry id from_id to_id other attributes...
LINESTRING (0.04 -0.04... edge_0 node_10 node_22 ...
LINESTRING (0.01 -0.03... edge_1 node_22 node_21 ...
LINESTRING (0.02 -0.02... edge_2 node_21 node_25 ...

Getting started

Install system libraries (only tested on Ubuntu):

sudo apt-get install -y libgeos-dev gdal-bin

Or use conda to install major dependencies:

conda install geopandas shapely

Install or upgrade snkit using pip:

pip install --upgrade snkit

See the demo notebook for a small demonstration.

Development

Clone this repository:

git clone git@github.com:tomalrussell/snkit.git

Maybe set up a virtualenv or conda environment, as you wish. Then install snkit in editable mode, with development packages:

pip install -e .[dev]

Run the tests:

python -m pytest tests/

Development checks

Configure the pre-commit checks:

pre-commit install

There are several tools and helpers set up to run automatically, on git commit and in GitHub Actions continuous integration steps. Each of these can be run locally too.

Run the tests using pytest:

python -m pytest

Run formatting using black:

black .

Run linting using ruff:

ruff check .

Run type-checking using mypy:

mypy --strict .

Testimonials 💯 👍 😊

With five lines of snkit I replaced four or five hundred lines of custom code!

A. Contented Customer (@czor847)

  • pysal/spaghetti has methods for building graph-theoretic networks and the analysis of network events.
  • osmnx lets you retrieve, model, analyze, and visualize street networks from OpenStreetMap, including methods to correct and simplify network topology.

Acknowledgements

MIT License

Copyright (c) 2018 Tom Russell and snkit contributors

Initial snkit development was at the Environmental Change Institute, University of Oxford within the EPSRC sponsored MISTRAL programme, as part of the Infrastructure Transition Research Consortium.

Metadata

Release files for snkit 1.9.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for snkit 1.9.0
File Size Uploaded
snkit-1.9.0.tar.gz 80.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for snkit 1.9.0
File Interpreter ABI Platform
snkit-1.9.0-py3-none-any.whl Python 3 none any Details

Total release size: 94.2 kB

Release files / snkit-1.9.0.tar.gz

Download URL snkit-1.9.0.tar.gz
Size 80.1 kB
Tags Source
SHA-256 checksum
How to use checksums
e715d608a100f54d888288e15b5a59bfbcecc863684bb47742150dd7e5171e41
BLAKE2b-256 checksum
How to use checksums
0852a73e2f18c29a1e535b340062bd30154f4981c3ecb57dc84e9b8d929a2dfa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.6

Release files / snkit-1.9.0-py3-none-any.whl

Download URL snkit-1.9.0-py3-none-any.whl
Size 14.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9304716dddef9c738c6d28d14de62e0ed8aab5c5bc3279eaefb4987b8f3e8f4a
BLAKE2b-256 checksum
How to use checksums
9f6739189931ef2397dcf2632f15a6f2e056c52054daef380012784c26411e1c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.6

Release history Release notifications | RSS feed

This release

1.9.0 This release

2 release files

1.8.1

2 release files

1.8.0

2 release files

1.7.2

1 release file

1.7.1

1 release file

1.7.0

1 release file

1.6.0

1 release file

0.1.5

1 release file

0.1.4

1 release file

0.1.2

1 release file

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page