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 extension/src
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 ./extension
cmake --build build/
./build/run_tests
Run code style auto-formatting:
clang-format -i extension/src/*.{cpp,hpp}
Run lints and checks:
clang-tidy --checks 'cppcoreguidelines-*' extension/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-*' extension/src/* -- \
-I/home/username/miniconda3/include/python3.11/ \
-I./pybind11/include/
Or with c++ headers installed on a Linux machine:
clang-tidy --checks 'cppcoreguidelines-*' \
extension/src/* \
-- -std=c++11 -I/usr/include/x86_64-linux-gnu/c++/11 -I/usr/include/c++/11
Integration of C++ and Python using pybind11
The snail.core.intersections
module is built using pybind11
with
setuptools
(see docs)
extension/src/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.1-pp39-pypy39_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 705b6322b0279393a97119d9daca53f729bb9cda4b76016f1b6412fbd13cfe5a |
|
MD5 | 785ad295493ce76bf850a1e775a6787b |
|
BLAKE2b-256 | aed3012291f8b5ece98ee57f58cfeb9996590e976b250cb41a4a6c76025e8408 |
Hashes for nismod_snail-0.3.1-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8ab53ac45d09d63c9b09cac7f6666073a246973ba0a18593f073422fdbe6f4e0 |
|
MD5 | 4cf5c9f53e7276a770a73a7dc7753591 |
|
BLAKE2b-256 | c33810d69d0b00c7ba9e8f0c8143d21bcee08101377fa0ac4a30b7107f4a538a |
Hashes for nismod_snail-0.3.1-pp39-pypy39_pp73-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 59c094ae546e0233a3a86c737a3b7b38ff3cf5235235d68460dc2c399f138096 |
|
MD5 | 3d785285b35813d809fada1b10035312 |
|
BLAKE2b-256 | f1168064a5f2079bdac1a98114751682edcb0a92f58b1e6bfa3a6e3949a0ef66 |
Hashes for nismod_snail-0.3.1-pp39-pypy39_pp73-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7660a6e2d489d96fd36a5c9a821c96912108520e4569bc083131e6ca6f6c2d4d |
|
MD5 | 569eccf8b4dfd014af8b163f96065366 |
|
BLAKE2b-256 | 3163d6e96bb593bf8401cd4f861c040ce65f780007c5781a8f98ca730856b6ea |
Hashes for nismod_snail-0.3.1-pp38-pypy38_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c15652453222ef1384d9910d2c73dc56780cca01302559405b6de1fa9800adbc |
|
MD5 | 47dac4df6d68ae342afaf4162fd6b2bf |
|
BLAKE2b-256 | 1752374f209aa45589c2384e5007e2a60e2db8e88e0da3fb2897f84abcbcea9a |
Hashes for nismod_snail-0.3.1-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1d2915b74cfb4e95e9e0dc82dd5174e68c2f90a45e316d2f539c30ba1aba927d |
|
MD5 | b9c33bbfb648c8b5a1659ebb63618310 |
|
BLAKE2b-256 | ee9253427cd316bc9923c2c867f925a6ac45c9d555b37279fce2fe3e64521bc6 |
Hashes for nismod_snail-0.3.1-pp38-pypy38_pp73-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cdb9d10ddc66889b3fb42302fe1f11baea241e5d87788435d127f1b58ef3ac18 |
|
MD5 | bb344f9dfbc0ce4735f995939a66cbe1 |
|
BLAKE2b-256 | d08d258a89bf3cd4b913b871264c343b8bc80e16861eb61a05d825e26816c9e0 |
Hashes for nismod_snail-0.3.1-pp38-pypy38_pp73-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e8310419c40f487dccd07add7b066ca15725bd68eeb4ae29d380ad59a29308b9 |
|
MD5 | 0d54b86142af8c4197ed54297b40febd |
|
BLAKE2b-256 | 3e2dbdb2e122a586b84849d536447535fbf4d954af876fccc5ce60e81bff1dd1 |
Hashes for nismod_snail-0.3.1-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c66a55656bd2c793a33cbeb1de45a11dd878b66dcd1f07d42eb5563b6ce90fe7 |
|
MD5 | 832a401fcee72844991c0ecc9dcf4bb4 |
|
BLAKE2b-256 | 57a1cfc09147a6761c20579f669f9cfe33107fa88e73a10a00bd521d1bc88ed6 |
Hashes for nismod_snail-0.3.1-cp311-cp311-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6241af45e7bc879846976f58101d6161a4913b647055eece969a7d216132d952 |
|
MD5 | 26286ccbfa3f6173c224c9fecc1ed396 |
|
BLAKE2b-256 | 6d239a1c1b98646bb0f7bf3b5a27822fb37dd092fb4938fd6d5a1b36e70174f8 |
Hashes for nismod_snail-0.3.1-cp311-cp311-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8d06d59d5a0ee4a9d7f373ac7599c936130ae21eb4274536fe1a8635d291be93 |
|
MD5 | cf109854f4207f471c2f4ab4d6873f37 |
|
BLAKE2b-256 | fd3e03b752d464b26df8021974df7dd602e67585bf8ffccc99a4634ed62d9d58 |
Hashes for nismod_snail-0.3.1-cp311-cp311-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e169d6c6b76827956315b55a0382857673a9ccffc8cf4be750dee7982a3462d4 |
|
MD5 | 0e1be48059094b40b599d47ee60d130a |
|
BLAKE2b-256 | e8e809285f006c8f7913d9ecdcbb94823eb805171cca6272a6e1ee8f33974633 |
Hashes for nismod_snail-0.3.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 646a3204259058fe783a2239bb3c1bc5b4d278eb7a7427db333019595ea7b8f7 |
|
MD5 | 9eb42c0244291ca5866fa8e8661c7076 |
|
BLAKE2b-256 | b98b9b01bef7e51214325b4a3b85c29d6474a00f9b7f5d8f61f13cdb9087bf29 |
Hashes for nismod_snail-0.3.1-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 10d51fb0e8712f2367a4c8ba7d1c892eea9b9cb9c74f2bae458e30097dc7d2c5 |
|
MD5 | f2c694d9653fcebec9ede87a8bb99983 |
|
BLAKE2b-256 | 77244537623aa0fb0ea331ac8873768acade7cb0f4b2f6f8e8a01e816eb99c1e |
Hashes for nismod_snail-0.3.1-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9cf14fa67490dbf9b3a932f5957654e1fef654cd30bdb851e448e3c73a527b22 |
|
MD5 | 67ae3f327805e1b21098cd019abee6a0 |
|
BLAKE2b-256 | 10fc25f51dc15df1ebfdd5f6a6536d8a5280679e2227e3fc77f7b47b944645bb |
Hashes for nismod_snail-0.3.1-cp311-cp311-macosx_10_9_universal2.macosx_10_9_x86_64.macosx_11_0_arm64.macosx_11_0_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e70bb9917e1d6ba84bcafc743b05b402820a73533980b80fbc59da3cb84f7e3a |
|
MD5 | 92d1005669cd77d08eeb950472bfad30 |
|
BLAKE2b-256 | 95479b667556c6fee43cfb060d0f5fe4865802682ab816146802467c2b37d83d |
Hashes for nismod_snail-0.3.1-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f99685252afac3e14552497052df7376950aef49402e677b2f76ff801cd11c66 |
|
MD5 | e51f34b0608299a205f2e622a3a7e50c |
|
BLAKE2b-256 | fab6a4d2e82a9cd2cc3820c62c55af680222e0286b6e6cf6a638b07ad697df1b |
Hashes for nismod_snail-0.3.1-cp310-cp310-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5eac73494cdf062337f1de6a6006eb1608c2f5974bc1dad17b3df3de145cf0a9 |
|
MD5 | b4a7f776e277a448e55c1dce22f52806 |
|
BLAKE2b-256 | 0e171839d3bfdabde4e8dd60e7e1796c2376098538a1fc1deb37d73087f8497a |
Hashes for nismod_snail-0.3.1-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 015d5c485ce6ce7b28cea8fc11f9c81fe91c3c6aa1aa692a7abfe999a9b74bb4 |
|
MD5 | a17835ca0182aaeabfa9b76e3f238e22 |
|
BLAKE2b-256 | 31effa6481713e4862598b4b799fd160f90a3e149dd72d563b34e5a2ea064f16 |
Hashes for nismod_snail-0.3.1-cp310-cp310-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 13c6610be0bc259930ac1c0e39101af530a036cee4e1d6c1c21f18402cec7266 |
|
MD5 | dfcddb72fe165fac1ee19026a2fd9647 |
|
BLAKE2b-256 | 17daa5da72035bf1c78317c9144b56c0f3219678e4da0a0f94e62225827ed286 |
Hashes for nismod_snail-0.3.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f841ab5fdbddcc7e7e9ff083f6c60bbc5884b11edce632aae65e0488e967e814 |
|
MD5 | bfbcc203037907e99c785be118615a86 |
|
BLAKE2b-256 | 719990a936c16c7426bf8e015afab43dab185dfe0885a12b926fb47c2755dfbb |
Hashes for nismod_snail-0.3.1-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | acd87525e8990fe7de244bd0246359742139c478caf2ef976d1ccff704b5cdfa |
|
MD5 | 4ed71fcfb5cf688a3cb345c0ec2a60f2 |
|
BLAKE2b-256 | 3c5db10535260288531ef9d91affb4a4b47189555fb07b3a3f0bdcc31d4c370b |
Hashes for nismod_snail-0.3.1-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 76fca4e7f596bc265c187a81b8a27bdd38c3cd1e1629be81fcff8c1cdde7ab26 |
|
MD5 | abc200587329494f8afb7823ef9bd295 |
|
BLAKE2b-256 | e5cd0a789fcbca728698bc49d7f227279cbdfecc3b83651a4493df48fba32d5f |
Hashes for nismod_snail-0.3.1-cp310-cp310-macosx_10_9_universal2.macosx_10_9_x86_64.macosx_11_0_arm64.macosx_11_0_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 72169eea146371c781040623af274a1ed795c1119fc4be6e5401b7c19193e7ac |
|
MD5 | 7e94fdcde1454339d4ee7c8bbeb0ccb9 |
|
BLAKE2b-256 | 0c30fa7f4c0d6b903d5101c5c43552df39e9f00dd0de6457966c3481531dbc8e |
Hashes for nismod_snail-0.3.1-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 989c588570297c4ea7de69afce6a787d591e48221199bddd14931cf31b7733d8 |
|
MD5 | b86ab865fe28eaff60fb6eb3d90ffe87 |
|
BLAKE2b-256 | cddfd7d58d1dd34a9a2b6e6494276d05971f4f008db3960776dfac99da1454f7 |
Hashes for nismod_snail-0.3.1-cp39-cp39-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4ed465909eedb72b3074cc34d843314a72d1f8ebb67725c6cf37b96048d4415a |
|
MD5 | 7cacf61a81265d34f894cdb701a25f17 |
|
BLAKE2b-256 | 9701e4912b7637f28921b64c6827b2e329ab01b4b9f6018550573fcb2de476ec |
Hashes for nismod_snail-0.3.1-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7819daf96a5f720351350f73162c32ae1eb525ff62c1eaa272ccbfa9feb272fb |
|
MD5 | 3cf115b5ddef2fe8618508ead334113e |
|
BLAKE2b-256 | eb3daf268b5c72044e595b32cd9220385ef40ecf41135b4723ce335d83de4d36 |
Hashes for nismod_snail-0.3.1-cp39-cp39-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e32ff43e86071bbbb9f93051ab6c275f3a30c82699c27694c0ff7d23a5c35af1 |
|
MD5 | 380f73e233bea9d3224b207b5a74f29e |
|
BLAKE2b-256 | da31c8fc11743c10d0b27a06dc4bd3166a691e3a682a2dd5cfb66e536cb09abc |
Hashes for nismod_snail-0.3.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9efc186630640442ee33315be4b98cbafdefc39bce4c0abe31d1d1a34647fce0 |
|
MD5 | 3148e0dc188ef9ec6740d0ba7cd2820f |
|
BLAKE2b-256 | c4e454b112f408f31eb91c8708d30037d9869384e090fba8647adb18ac26ba69 |
Hashes for nismod_snail-0.3.1-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5b7426a37953f879b3262a8c4773c69f877d1b83d4eba9ee87c0e710bb7a5059 |
|
MD5 | c1fb5fbeaa9a5d04435e232ef10a30cd |
|
BLAKE2b-256 | 907ba582a40925da5fbc544e912a9a562e8bb4ea7bf135caf564b67f747e462c |
Hashes for nismod_snail-0.3.1-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ba7e809f48a01612b620a663bc90e4b34c6d72bbe81c6bf8d0103d34389d20a7 |
|
MD5 | 3a47899913c8a1a6d874ea554abd128e |
|
BLAKE2b-256 | 342d1461c6322399a61389a35ff86fd74ccec5513f1c5df5670a671fe5d2a26f |
Hashes for nismod_snail-0.3.1-cp39-cp39-macosx_10_9_universal2.macosx_10_9_x86_64.macosx_11_0_arm64.macosx_11_0_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f3d63e5a94f9c61b5fd57f1e2bd11cc2f7f2f9713657abdefb665917600f76c3 |
|
MD5 | ac72ad88facc8f433c35158b312baf8f |
|
BLAKE2b-256 | c0a696a87238591015cafbe5786381624c4f819df6d302c40099c773e6484124 |
Hashes for nismod_snail-0.3.1-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0b3ed185c6e64d49a0aefc9c59b625f0feb57b532cf248063d701a36ef320020 |
|
MD5 | 5e324b189b716bba80a484d9b7049d96 |
|
BLAKE2b-256 | b5a97b1e46aa1fc5184ad14013aab45e38c3ee24b9a5d050cc16220e5f78562b |
Hashes for nismod_snail-0.3.1-cp38-cp38-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fab2e8ec9941092c4b15807442b5ce27db62dcd618ead7f9cadcf049409909c8 |
|
MD5 | 179db608c50c4394bc8e1a3d1d2f0f77 |
|
BLAKE2b-256 | 312d2ce3d4b3d98704e69c26c82cf6165e53ff1804e7cdc5520bf2ff06e46715 |
Hashes for nismod_snail-0.3.1-cp38-cp38-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 355a0da099490f505c63f6f659a7159f29137efeaef40ccabdef5084a605fe83 |
|
MD5 | 540f8a845c311c8bcd26926f2c99a0c2 |
|
BLAKE2b-256 | fa9266ab758d2bc28f9fdec7860be65d0e99ab9996527a076669cd3e929691eb |
Hashes for nismod_snail-0.3.1-cp38-cp38-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c3d38e1e59d7ced84454c68059a34bc7f9abee56b14158752262eccf90ffc2fb |
|
MD5 | 49975ad8749dc7ca32bd19c92e43b7f1 |
|
BLAKE2b-256 | 3e70ff44b12326e3e838a1dd5a03cd9871b4a7f03d298e8d68f47fb2308e96cf |
Hashes for nismod_snail-0.3.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0d1141d1d25f6c6250b1b2f7854830026191a7a77e845171e4c076c6977cdfd0 |
|
MD5 | 99bd7bcbabe543a95a2cc22eeccfba19 |
|
BLAKE2b-256 | 9bdf3594642e86a4478186536e843e7e09af6849a1f33293a3c1fc1a76e23ae4 |
Hashes for nismod_snail-0.3.1-cp38-cp38-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cec407e7af96fa09de6b9dbd75eeb49ab74270bf6d736b5ef62d73e68403215d |
|
MD5 | f6d56e7dae1a8d6c7fe741b329b2f761 |
|
BLAKE2b-256 | c632f00562ee607b4319788a3acc2388e6e80ddff994c14fbb6c4053577e49ca |
Hashes for nismod_snail-0.3.1-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9e2bee471d52cdff38c448b66afa08c7161227506c82898c23ccde11231a6791 |
|
MD5 | f975ac795e302aa2c29cc447bb6c6a70 |
|
BLAKE2b-256 | ed697094ca9b63b67322fd0811e6106c915a3262049e902be86f355e33ddc197 |
Hashes for nismod_snail-0.3.1-cp38-cp38-macosx_10_9_universal2.macosx_10_9_x86_64.macosx_11_0_arm64.macosx_11_0_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8a8c04f0b6cf7d0b90040181bb3eeaffc129cd9b8bde3f484b3a8d444303dd57 |
|
MD5 | 436ec9f69dfd2a5eafcac9aca0aba66b |
|
BLAKE2b-256 | d5cd72a6653258005e5aa5900c84e7d24a0f5cd31a306f898d31c75ceae0d894 |