Skip to main content

a spatial networks toolkit

Project description

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/

Testimonials 💯 👍 😊

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

A. Contented Customer (@czor847)

Related projects

  • 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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

snkit-1.8.1.tar.gz (78.5 kB view details)

Uploaded Source

Built Distribution

snkit-1.8.1-py3-none-any.whl (13.2 kB view details)

Uploaded Python 3

File details

Details for the file snkit-1.8.1.tar.gz.

File metadata

  • Download URL: snkit-1.8.1.tar.gz
  • Upload date:
  • Size: 78.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for snkit-1.8.1.tar.gz
Algorithm Hash digest
SHA256 b1c2f482337cc7cf185a9e312aca46deb5262578b3215714772da8b85194bed7
MD5 dc17c62b6827e8bd9a604db8e23717fa
BLAKE2b-256 f73583fa04d7a585fa945b39a83cdf47c75ecd4f4e19b7138f63795538160245

See more details on using hashes here.

File details

Details for the file snkit-1.8.1-py3-none-any.whl.

File metadata

  • Download URL: snkit-1.8.1-py3-none-any.whl
  • Upload date:
  • Size: 13.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for snkit-1.8.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a52dd23552329313f5d7682b58bfed5bdad438111e543ef6b370d4455659fa9d
MD5 12ed83817e247ef88a69cf7135c3d441
BLAKE2b-256 845c188ab71aa913e61547065b0515e3e0b3845467c86642bbc3a7954d6a2f9c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page