The spatial networks impact assessment library
Project description
This code is under early development
🤔 What is this?
This is a Python package to help with analysis of the potential impacts of climate hazards and other perils on infrastructure networks.
Installation
Install using pip:
pip install nismod-snail
This should bring all dependencies with it. If any of these cause difficulties, try using a conda environment:
conda env create -n snail_env \
python=3.8 geopandas shapely rasterio python-igraph
conda activate snail_env
pip install nismod-snail
If all worked okay, you should be able to run python and import snail:
$ python
>>> import snail
>>> help(snail)
Help on package snail:
NAME
snail - snail - the spatial networks impact assessment library
Using the snail
command
Once installed, you can use snail
directly from the command line.
Split features on a grid defined by its transform, width and height:
snail split \
--features input.shp \
--transform 1 0 -180 0 -1 90 \
--width 360 \
--height 180 \
--output split.gpkg
Split features on a grid defined by a GeoTIFF, optionally adding the values from each raster band to each split feature as a new attribute:
snail split \
--features lines.geojson \
--raster gridded_data.tif \
--attribute \
--output split_lines_with_raster_values.geojson
Split multiple vector feature files along the grids defined by multiple raster files, attributing all raster values:
snail process -fs features.csv -rs rasters.csv
Where at a minimum, each CSV has a column path
with the path to each file.
Transform
A note on transform
- these six numbers define the transform from i,j
cell index (column/row) coordinates in the rectangular grid to x,y
geographic coordinates, in the coordinate reference system of the input and output files. They effectively form the first two rows of a 3x3 matrix:
| x | | a b c | | i |
| y | = | d e f | | j |
| 1 | | 0 0 1 | | 1 |
In cases without shear or rotation, a
and e
define scaling or grid cell size, while c
and f
define the offset or grid upper-left corner:
| x_scale 0 x_offset |
| 0 y_scale y_offset |
| 0 0 1 |
See rasterio/affine
and GDAL Raster Data Model for more documentation.
Development
Clone this repository using GitHub Desktop or on the command line:
git clone git@github.com:nismod/snail.git
Change directory into the root of the project:
cd snail
To create and activate a conda environment with snail's dependencies installed:
conda env create -f .environment.yml
conda activate snail-dev
Run this to install the source code as a package:
pip install .
If you're working on snail itself, install it as "editable" along with test and development packages:
pip install -e .[dev]
Run tests using pytest and pytest-cov to check coverage:
pytest --cov=snail --cov-report=term-missing
Run a formatter (black) to fix code formatting:
black src/snail
When working on the tutorial notebooks, it is recommended to install and configure nbstripout so data and outputs are not committed in the notebook files:
nbstripout --install
C++ library
The C++ library in src/cpp
contains the core routines to find intersections of
lines with raster grids.
Before working on the C++ library, fetch source code for Catch2 unit testing library (this is included as a git submodule):
git submodule update --init --recursive
Build the library and run tests:
cmake -Bbuild .
cmake --build build/
./build/run_tests
Run code style auto-formatting:
clang-format -i src/cpp/*.hpp
Run lints and checks:
clang-tidy --checks 'cppcoreguidelines-*' src/cpp/*.hpp
This may need some includes for pybind11
- which will vary depending on your
python installation. For example, with python via miniconda:
clang-tidy --checks 'cppcoreguidelines-*' src/cpp/* -- \
-I/home/username/miniconda3/include/python3.7m/ \
-I./pybind11/include/
Integration of C++ and Python using pybind11
The snail.core.intersections
module is built using pybind11
with
setuptools
(see docs)
src/cpp/intersections.cpp
defines the module interface using thePYBIND11_MODULE
macropyproject.toml
defines the build requirements for snail, which includes pybind11, wheel and setuptoolssetup.py
defines thePybind11Extension
module to build - both the C++ files to compile, and the location of the built module within the python package
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for nismod_snail-0.3.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6e12729f2d8e84fbd5a429ade89afa35816a897704eb90a739b87114fe8377f2 |
|
MD5 | df7e477a5dd8ff65415cbe216f8a9dd3 |
|
BLAKE2b-256 | 3e904ffd97b005682fe4641a0d8c786f18c7ecb7786bb348d5236ef77564a0ff |
Hashes for nismod_snail-0.3.0-pp39-pypy39_pp73-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f4db101385d64d2383f07dc69094a3b3cb3f16f8eb736b3a103f6d51e2ec4b54 |
|
MD5 | 220cdf3a7a726b03ebecfa347b7e4428 |
|
BLAKE2b-256 | 84d46e9862daf7866c6c29cc6d73868e54f1bf3d06ab8dd4f4ba2fa8852d7a70 |
Hashes for nismod_snail-0.3.0-pp39-pypy39_pp73-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cd7414cef40e1f08a28cccbabcc88c804fb34bbf8f8be48268c2d1dc44ed5e6d |
|
MD5 | 2ed7cb924d588f96ef3d9c2461ba1a4a |
|
BLAKE2b-256 | d9d9a9cbeb4de280e559dacb8f593c7a20812734b3b043bc1aaec9db0a88ae14 |
Hashes for nismod_snail-0.3.0-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 38105cd5f4b6472d0826c766ba6bf467e7554fdfb1585fdb405db7af0fceb9fe |
|
MD5 | 9f1f4f317c6d96382830285d33c172db |
|
BLAKE2b-256 | f0cd981750bce65625b5f6e85f807f708cecd9e70bcb04a63f678da3728dae6f |
Hashes for nismod_snail-0.3.0-pp38-pypy38_pp73-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b359f4e8db1ab799e44838a150ad1041a42bc7717d1157fb660118d81e8be479 |
|
MD5 | bd1291f52a64b1631a2041d9392bf77d |
|
BLAKE2b-256 | 9b14008ff5ec6ab4387d24cf48b00990f1cce47290b869728d4e6cb412c575de |
Hashes for nismod_snail-0.3.0-pp38-pypy38_pp73-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5a3490c6835968f0a5effa0a40c9f106ed2435cb7ca383071411b1e8f236d60c |
|
MD5 | 2ec7e23cc2a07640a45da8768b724812 |
|
BLAKE2b-256 | 1447e58c69039d4bc40a56092a802049dab2f1fae608bd197e77c96280f57b31 |
Hashes for nismod_snail-0.3.0-cp311-cp311-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1c30a20458d99eab8dc0ee80af4d819bd722df2b18d88630b4338fe4c01929a0 |
|
MD5 | df6aa8a81b6a5548689f4e5419e53520 |
|
BLAKE2b-256 | 44723da19468344064b8e68ae7b59bfc00d06e60046f0dcb6b9a15a50fda25e8 |
Hashes for nismod_snail-0.3.0-cp311-cp311-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d3741c0b316a860cffcd7ce8408417f392e93e619919e23a5c2d4bab709332a4 |
|
MD5 | 5869b9163b17484aaa57523f1423e51f |
|
BLAKE2b-256 | a64cf6c4aec2cbda2f5b7dd2f89489c5dadb3e2a78468a987610fe611fc8cbcf |
Hashes for nismod_snail-0.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f47fb3298345d7508d031802992b2ee521a2f3e657121f769adf3a0a252067ac |
|
MD5 | 6b1a5370e36a8f82b436335981dc177c |
|
BLAKE2b-256 | fa561c8d07aa69f6c53d60fe55bcb360645dee705582b400257cd89c55947c3a |
Hashes for nismod_snail-0.3.0-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b390f72f8c066eea59a735e0693a0d88eebbe9e40c388d279d6b49d2a0cf4d31 |
|
MD5 | 0a44b40c28ea8358b2136495bd774e08 |
|
BLAKE2b-256 | 9c0bab94d189062571dbd24606d5b8e25c41d669e21f8a2e68428630de537d5e |
Hashes for nismod_snail-0.3.0-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d69f887c8e3dc0759999533bd6b1f8fe7404b01a2edd20b930859e82622df850 |
|
MD5 | a3d8f67f5fcf5d6daa9dc6e6826ebeb7 |
|
BLAKE2b-256 | 47e92043365a2e5c8af1bf5946930236f8cf6f2c0a1281d0bd29942a7ce9a0fd |
Hashes for nismod_snail-0.3.0-cp311-cp311-macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fc5508cf59d5bbbde4579a6f5521654cf6ab7ef5c93174cffa101adca5fa763e |
|
MD5 | 9d30e475e89f4674cd0c41b3c6739c44 |
|
BLAKE2b-256 | 5ad0665bfc7b8f9dab800377ffdaa063038e8dae09acfffbf79c53e65958a8e6 |
Hashes for nismod_snail-0.3.0-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c974ab0df726f917703e8fd84fdd160154eb6d8ac4b5a4fa61867b79a5277827 |
|
MD5 | c79d51983ff56d171d21024b5dca9673 |
|
BLAKE2b-256 | 557d860b9fc96632a0c440421f13c1890049dfb73a5dccf7c3269beacb07f25d |
Hashes for nismod_snail-0.3.0-cp310-cp310-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6ade13536917563652b58979e5c0483d1c7f61485f221a33f918d84b08ef6ef6 |
|
MD5 | 01009de669845ecf534e7d0522e4588e |
|
BLAKE2b-256 | 85dd9a9725af40f966678ed38cd4afda1bf3736a258ee3e390a9a9c6570bc86c |
Hashes for nismod_snail-0.3.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 80acc50681a91ed5e4d1657de5a8a60de0df7162ffc1913436764f9cb8b0131e |
|
MD5 | 06454cad5966e213219808094abad9f7 |
|
BLAKE2b-256 | b9a001399c018fa09b409894ed19f42a7efe7b20d57aaa444a8a067e13ec95cc |
Hashes for nismod_snail-0.3.0-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 483dfa03c44ba84cd48aa2b4d54ffde800fefd241be0dead79a8ce83a44ab1fa |
|
MD5 | c74a72010cac7314605a17c40f7d52a1 |
|
BLAKE2b-256 | a8a1d2de5aa88db4b6ab22f5d8080819e84d760a4b75c42b3977f6fc4575322a |
Hashes for nismod_snail-0.3.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cd5ffc0b0883dd9885a3f3ffba469c79058ca1ae4747384ca743716f375eab03 |
|
MD5 | 44b396b2c03a774fa4051e5150c245ff |
|
BLAKE2b-256 | dde19256d56cbc0689966fcc6037fba90a44c20758fcc2a55479678f7dd5d56d |
Hashes for nismod_snail-0.3.0-cp310-cp310-macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fed91c40294d580fce1fcd793b6494c7e749ef803a0b431496ca90641bb1a821 |
|
MD5 | ffe56bba355e02a17c4be82d070dece9 |
|
BLAKE2b-256 | f400910fb58a0d15dd4bddadad2f7fa3c28b4c6fa07d297de46a4e5f1dbe1e1a |
Hashes for nismod_snail-0.3.0-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 34aee0d27c5f23ad80c38a38b6cf8c5b8cea60c563a8a5ee7a49838bfac6444f |
|
MD5 | 08618ec6fe23da4a5a9e3c55ea3cd7d2 |
|
BLAKE2b-256 | b815c12e1890a16f04a00d8b5d38f16e61d914b57810a277bc69ed41b04cb907 |
Hashes for nismod_snail-0.3.0-cp39-cp39-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 245bfbbbf8b77c8d76022852eca596cb77cb99f555acd3643467927a1b33a2aa |
|
MD5 | 4d3337f41d5543f39d3358376eca6824 |
|
BLAKE2b-256 | cd4c532c5d4b42b2d6af99e4ca86628b27306d802a413045845e7e33b37182db |
Hashes for nismod_snail-0.3.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d5e24786502ebeef30eb0ab77efb9b5faf2ee4f774adc07f68a68871f12f5970 |
|
MD5 | db6cbb2191a62125adbf6d5279e28773 |
|
BLAKE2b-256 | 95f616cc5f0b510dba43df3b7b23f67ec2132abf5833a562b11ff1b9a75a57ff |
Hashes for nismod_snail-0.3.0-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | be54903434d80e60ccb397df1e8f0339aeb3ad1d486f26055473ebc114eb3b5b |
|
MD5 | f8591ea3cab9839111d8702b671397a7 |
|
BLAKE2b-256 | 7b8ac4b10d0fbddba0ddeb40fb027faabe154a471752017490cbf0e5dc90b33d |
Hashes for nismod_snail-0.3.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dec46d17f11bf943e4336f70f7d66a14e22dea685e46765ae63400ec68f1016e |
|
MD5 | efa3ba1ce7ce6344de75beab48f4114b |
|
BLAKE2b-256 | 0981a6fa7cd137dbc20416dd5388f2f07700fd673ac4348cee626c1e3c67e874 |
Hashes for nismod_snail-0.3.0-cp39-cp39-macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | da82c340a471e357fa8c092d6aa0c9b95a01bd9cb0748ff850f5e6fb1b692f20 |
|
MD5 | f3b8625e48b25acf22e9adb55f472c5a |
|
BLAKE2b-256 | e5883c45edb07f41cf72c177e05a1ae2ed16ab313f2e382bc16d17efaab87582 |
Hashes for nismod_snail-0.3.0-cp38-cp38-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5a12e27771312df7ab21ce83b03f851d44542bc900a4819ff0e2e639dca46170 |
|
MD5 | 2929703c08ced02959e1ead0cdc38645 |
|
BLAKE2b-256 | 850e4c712d7e3b1c0a6e2bd96789f340f6e8a3c7dd2766303d1c13672d44e669 |
Hashes for nismod_snail-0.3.0-cp38-cp38-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6d7836e03a8f62835e563c6e8c4054e21a3a8aa0785fb84aaab1e521ad23f230 |
|
MD5 | c7e1308dc9dc98b5f5058e624cc408cc |
|
BLAKE2b-256 | 3b44108487430e6d32ef0d13163a41b860ec6d34de78521ae727ed673face692 |
Hashes for nismod_snail-0.3.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c3c6d39956a396706f9cdad4e9e3bbdb6e8b9d3fa2c4e5fd2ae8430cf42e9ca0 |
|
MD5 | d85118af0acc23b1e3bf35376d8a0a32 |
|
BLAKE2b-256 | df450d650055eea5de8b62aa2e6781028c12133b78515a6d4dd80d4e234d9cec |
Hashes for nismod_snail-0.3.0-cp38-cp38-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b8625eddb3c3301caf4912c84a240d191241c4e14b11bf3f034b2d842a93b415 |
|
MD5 | 582c8aa965d0825f557ebe839a4ef4cb |
|
BLAKE2b-256 | b98a5c3a0a64b8b607d4dbb5e77a94f6a1b940c9792adf8fa35e3c18df14adfd |
Hashes for nismod_snail-0.3.0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d60a72b4ecc0ac5c4d904c23942ba33e7338976ef81c772c9c36be7ee5cbb3a9 |
|
MD5 | 79e3828f1c184295369ff48d222371e5 |
|
BLAKE2b-256 | 370173757c941cc634e5d248d037599ef44d409ddf8cc64e310a0e7f80f7c0e4 |
Hashes for nismod_snail-0.3.0-cp38-cp38-macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bff3612426efbf439af556012f952d4c70720e7b5527762073b36b12ee0365d9 |
|
MD5 | bab22192b86835043b5e2a3e6739fe75 |
|
BLAKE2b-256 | e536770f64f27ccff7e15c326169dc7e25fec3856af2c1bb620736c4bf81fece |