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++14 \
-I/usr/include/x86_64-linux-gnu/c++/11 \
-I/usr/include/c++/11 \
-I{$PWD}/extension/extern/pybind11/include \
-I/usr/include/python3.10
Integration of C++ and Python using pybind11
The snail.core.intersections
module is built using pybind11
with
scikit-build-core
(see docs)
extension/src/intersections.cpp
defines the module interface using thePYBIND11_MODULE
macropyproject.toml
defines the build requirements for snail, which includes pybind11 and scikit-build-core
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.2-pp39-pypy39_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2752edcc3aeb3cac5d7a384ebd8386f5c17dab53eec46372e89fb590be0097d2 |
|
MD5 | e47ad3d0ba610528a4d13c8794a9e50c |
|
BLAKE2b-256 | 42393f94126a3e25aeb32a798736a8aa6ce9226ed03d6f19613859282a5fa76c |
Hashes for nismod_snail-0.3.2-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ae330a4574b0e82eda9e40261fee941cf484bdd9a45b0ff6bbacaee2842a7632 |
|
MD5 | 751db7cfca6e910f4dfbd3c9a680d58b |
|
BLAKE2b-256 | 3b3049cec1c7fb5a6c64422ecab3baa36ad6951a0329cb3e03e8fa86998c9ac9 |
Hashes for nismod_snail-0.3.2-pp39-pypy39_pp73-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d39478a262d3eb71ce2c20920aabc6f0d22d99ca45e81a7bab2ae0603c94995d |
|
MD5 | 96ce223a1ea7f72252ca88d77831d04c |
|
BLAKE2b-256 | a6a4aed16169498090f5eab4d8b6df86243a3de9d4eb98034f40603341128891 |
Hashes for nismod_snail-0.3.2-pp39-pypy39_pp73-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d3b8f885534be1cd176a793c6371c247df12a51bfe5c48042a3a5e0c0aaf8551 |
|
MD5 | 74e75339eb5c1d9c1a667a6883b774bc |
|
BLAKE2b-256 | 31d42c1fb020d80e7f8d744e3d635c50d2f8b7acaf7fbfc5cd58ea42e88c9b67 |
Hashes for nismod_snail-0.3.2-pp38-pypy38_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3eb5f629922b7e60f7ac6d0a56a489d304107884c244c4105503aa7a9e10e92f |
|
MD5 | 97d3255d98fe783966deaff09672e435 |
|
BLAKE2b-256 | a8f0730bda7c86e169d4390f1149b8c7d9b2176524d86e432b30d3f5021d4109 |
Hashes for nismod_snail-0.3.2-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e3ee5f3542a04fdc64bd4c2fc33fff10b6db900e0495fcd7696bef1d7c809fd3 |
|
MD5 | 76eacc53e7ae514aa7991d81a93a010a |
|
BLAKE2b-256 | 75519ab5707faaf2bd21fe12388b7ebd476792b52c810344db90ba47116578cb |
Hashes for nismod_snail-0.3.2-pp38-pypy38_pp73-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4a5f480e1d3974aae2ebf28e4bf0691d5c21b63e3e862ed1d2567a7943fa00d5 |
|
MD5 | 53263e111a2ba3fec17b3c0a9e041044 |
|
BLAKE2b-256 | 3e1f403d2ea8099b7244d612ff489f1fed86e786538c8a998c770f186005bcfd |
Hashes for nismod_snail-0.3.2-pp38-pypy38_pp73-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 688f9626adcf9051fe361cf869c6c20bf7a65038d5cea1110719e4cd98aaf189 |
|
MD5 | caae4b412a746115def230700922d761 |
|
BLAKE2b-256 | d03ab84f864b47428333dc4bdafc3d529a3f6ce41373f0ec5298141d8a60ce30 |
Hashes for nismod_snail-0.3.2-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 27c223ceb2c6e75e3f73036dcefeea34f15a979c5f58faac64322deb3ca8a325 |
|
MD5 | e447f4a1788b8ed547b456ee522ed540 |
|
BLAKE2b-256 | af36f9579770f24d265114affbab0f81718fd7a8022664ab73e66b93fa2b1075 |
Hashes for nismod_snail-0.3.2-cp311-cp311-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d4eea5c91f5f708faffe45ce74a3ea128476fe70a9da603031a8402f5af89142 |
|
MD5 | fe5e244fd91655690888a146e57240d1 |
|
BLAKE2b-256 | 3aa49f3f9271dd9cfa5c4149848a57b422c2ef9a0201492e3d99d46591e221ad |
Hashes for nismod_snail-0.3.2-cp311-cp311-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ca1b8fb01e0da38345f0dcf31ab9f5eaa9c491d0f55216fa569eb76da439e354 |
|
MD5 | 5cd3e914d0243752c51a749e4f56b289 |
|
BLAKE2b-256 | 24ace2ed32810f12ab48b730c6f4972c95d89449e5621c5bc73d2095de832edf |
Hashes for nismod_snail-0.3.2-cp311-cp311-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9236c79acaf9b5bd584e76b46de7759039d1b922a9b522098987e19ff10be72a |
|
MD5 | 8d4a01e430939d4d71a688488ec3296e |
|
BLAKE2b-256 | 77bee4049856937b637c8558949f1ccafb803b1bf22dd883fba52cf59e579a4e |
Hashes for nismod_snail-0.3.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 745e4cd9921123b8e916827f3c2d9d02937b75c8fc1e6c5b544ffb8b5cff3866 |
|
MD5 | 26336b4086fc892094db2a8fd7204737 |
|
BLAKE2b-256 | f4329f49c865ecdd9cd3c0fd5cce821f943c13f2e44e51269ce17da0cc2ca54d |
Hashes for nismod_snail-0.3.2-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b41fcf6e149e333c758893af349c29d74139d3b2baecd5fb940501b27e7fe122 |
|
MD5 | e1e543363314ffeb24ead82800ac42d2 |
|
BLAKE2b-256 | dd9a5dbc18dcfef4f1e1dceb985b1d89cdf58734a98e08281c28e1e563534b1d |
Hashes for nismod_snail-0.3.2-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0e371f91e6eb123c987052e9e1becf9edf7e0fd74f0d104314f00928097a87b3 |
|
MD5 | 63a2ff702bb39952def87fe9c7281ec4 |
|
BLAKE2b-256 | 451c353ce5c2d1aac30055b9c938f39a2c17c7a690543ef53e18d0f06b32cc00 |
Hashes for nismod_snail-0.3.2-cp311-cp311-macosx_10_9_universal2.macosx_10_9_x86_64.macosx_11_0_arm64.macosx_11_0_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f03d784c4be341aa4d9420eb6bb2a5089776ab2c712c24fb239e91d10673270e |
|
MD5 | 8f15c997a703f6a344053bd40d984f15 |
|
BLAKE2b-256 | 6b7efb7092a8a4d3901616077e9b21e8f2f48d4d8b46104e644a8a439fc4f240 |
Hashes for nismod_snail-0.3.2-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 322589ce4f389d32e07f3fc45d6c2a526d7d5ee2215c41a7defba007e5c7b7c9 |
|
MD5 | 16aa70de2ee0f870d677d2ee25e9256e |
|
BLAKE2b-256 | 907e985e1151f5d937522b4834dac54848e0fa727495f20bd5e4436a5383d375 |
Hashes for nismod_snail-0.3.2-cp310-cp310-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2a389125a1b88fb85adf7fb16a45f450014c014040d35282ee31737ab93ceda5 |
|
MD5 | 305f7ad0f4fcaf044499ef08d673600d |
|
BLAKE2b-256 | 63845cbfd844b60e09057d889294e2311f90e9ee651fefb879cbc5a8e7418615 |
Hashes for nismod_snail-0.3.2-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c57c6bb31480a1880a139092db9766f944935be4e79fab2bead1700c01c2f115 |
|
MD5 | 9e9e95951aac3f17fdc259e18c01e1eb |
|
BLAKE2b-256 | 9ef98835da23db9745d51ebcf6c481ff85563f1d49ec41ffdf068bda0d2102f8 |
Hashes for nismod_snail-0.3.2-cp310-cp310-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 75b8e1551acdc020ee3ea0343b954ea19188cc8f612b6d8659e9b5fddee855e9 |
|
MD5 | fccc626768742f47e2ea48e871dbd208 |
|
BLAKE2b-256 | 8c0739364745b5d868f95ea60e02b99875afa120a26e631e35ea53b456c57f99 |
Hashes for nismod_snail-0.3.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 829eba2f2fca12c272e6f8677506c0b9d374d442b2bba5ee0289987bc96025ab |
|
MD5 | f30dc9c0c38a32256c9779188134951a |
|
BLAKE2b-256 | 77d9a2633612cb35417aa3ea44944f331fabccd856a2251f8827bc0cbd42e3c7 |
Hashes for nismod_snail-0.3.2-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e3d542224c398aefdada98625dbf5e080edaa7a38bdea26662cd2d3910be7e44 |
|
MD5 | 838bae788296fab325281afdf1095f94 |
|
BLAKE2b-256 | a6bf721e57aa679241de071b34967f6567447c9979fc2a60f105c3f1f3f145ac |
Hashes for nismod_snail-0.3.2-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a1e729a0b2da7e205f8ec48a1a3da1e5d857f022466cdd279f6a76fd4a7d0a84 |
|
MD5 | 0c24699e6d7c18c509369b6c565b2460 |
|
BLAKE2b-256 | 20555db0b7e631d6582bc6e12d79b37102aa28caeb04dc2fdf54fcfd6fd76b61 |
Hashes for nismod_snail-0.3.2-cp310-cp310-macosx_10_9_universal2.macosx_10_9_x86_64.macosx_11_0_arm64.macosx_11_0_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 425b3a1ab64b6699c002fe7640cfe89d9bbe7985cf8ba02bc978e34f7631d40d |
|
MD5 | 4c18f674700e4d1fb23c14d4d81878b7 |
|
BLAKE2b-256 | eefb7c0fe85ff5dc5131b894fa59e632976f3928be2ce090bdce55f8653ec662 |
Hashes for nismod_snail-0.3.2-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | be7f1cab4d1ffe2073e1b68b3f6d33d2bbc4dbdd537e4e8b8417ea8b00cbee2f |
|
MD5 | 595dd596245ecc2cc4b187d89294d31d |
|
BLAKE2b-256 | a6d8a0c7ef09acaa25b9b8dd342aeb28713c70d0156a00450b0ee22b6734297d |
Hashes for nismod_snail-0.3.2-cp39-cp39-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 65129eed8e8ec10b3137b109a8740c89886268e7715c446d16fb84d1ead1d111 |
|
MD5 | d2da09e3703b9c3ca4655e11eb16bb20 |
|
BLAKE2b-256 | 9b3d0172ecb51925276b1f2f872d95ae5e527e7a8db3624c83234592bf0c95a8 |
Hashes for nismod_snail-0.3.2-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b34a57175e39bb150cad1b93c9e5d47d0404ef11df0fa8ff57d9e4a18a80de58 |
|
MD5 | 3084dc224ae1b6e07481e1ead1144800 |
|
BLAKE2b-256 | cffd5801faf226a00ed05255c676fa62e80b7c58c84b682cdb42871b5f779a7d |
Hashes for nismod_snail-0.3.2-cp39-cp39-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d40d291f5635802dd5448bee88c38182396654989ff1bef38512e612a892d5d1 |
|
MD5 | fd421b81ed3208729a6fff523cfb3194 |
|
BLAKE2b-256 | f8c6b735e5565795a5d2d8605a5f881fdb4c6823a29362d16a14bc23f73a42c8 |
Hashes for nismod_snail-0.3.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 122dc6daeaf2ca5e094fa55872e43196179b63447264260b29566c0ec9451ad8 |
|
MD5 | f99e3fff4becd9c76c991133329a74fe |
|
BLAKE2b-256 | e7894926976d50a98721508cd4496bea09ce85e90dc3e5a8026549bb4a0ac7d0 |
Hashes for nismod_snail-0.3.2-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cff8051132c8282d5e131ab4799892e799594d2957ca335d88f9c31a319cf1a2 |
|
MD5 | 451cd8bb82376634418cc37873f1ea2d |
|
BLAKE2b-256 | 26caee5e3fc8b014ecfadcfe468a7b7af0817fa47d5130d474a524a67be57fa0 |
Hashes for nismod_snail-0.3.2-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 20913e974e9163d79dbc658b4773c081f8b317be27eaeda8e13c93aed8b636c2 |
|
MD5 | 7caac86b539b8483d96f1275dcfa900d |
|
BLAKE2b-256 | 14162c8453ee3c7ec7a671d4f5dbbcf2fb1ca8f552517f3406e6c9b47765b065 |
Hashes for nismod_snail-0.3.2-cp39-cp39-macosx_10_9_universal2.macosx_10_9_x86_64.macosx_11_0_arm64.macosx_11_0_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 49f968bee67fbe7a6631121278bd131aab754f14f064de73392c9cd5da2449aa |
|
MD5 | 081328cfded089f2cc53ea351234c2c5 |
|
BLAKE2b-256 | 5621439ae74b0a91bff2214cb9d7f7754646e36a5ed2c98b72981aaec0bcbd74 |
Hashes for nismod_snail-0.3.2-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b5c527388003fc396aca6556d407afeb365ac95e188816c51651cacc790bbde2 |
|
MD5 | bf38195bb27ac0e567b0b1365e1ae396 |
|
BLAKE2b-256 | ca5032672262e7070dc8a416cf087e7add0178b9876fdee0b664eff6ac039143 |
Hashes for nismod_snail-0.3.2-cp38-cp38-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 087e993d7f1e168812b09ec18b6e19494f6bf90e6f0ef426c472aed123617e4e |
|
MD5 | 03a42acd963135d3a759927e2ca16845 |
|
BLAKE2b-256 | 9513717af36a7fe27382da2b9c4260519fb64cd23466d41df95b2008769b68cf |
Hashes for nismod_snail-0.3.2-cp38-cp38-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5e92954455b67c4db0995908d97795b821327b2cb21799cbad6f9041d96e0ee8 |
|
MD5 | ae483d7e294dd48bc5d05169f8dd2fe9 |
|
BLAKE2b-256 | 6a6a29b915abd05fdd74df8d1255224679c6cf1391376acfe7e47a4f19b8753a |
Hashes for nismod_snail-0.3.2-cp38-cp38-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0aacb2b7cbce50d26207b833e9cac2808b2392e06b0c97f55f9a2008cc568986 |
|
MD5 | 3d7a43eb6b009803defe302e94c2a21f |
|
BLAKE2b-256 | 3398d4c7a3407e5d486ca146b1f15455ef0257df45b3f6f18d4c8c06c38773be |
Hashes for nismod_snail-0.3.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bea172d2fb2a2c35baaabca1e6c66ad86e558f4d862207741a4a329e0b0e34a1 |
|
MD5 | faa14c92292be062447834004df89410 |
|
BLAKE2b-256 | f71364b270954c69248595a1224e1fa7a732a82801e7462e60f4430ff43ad9f6 |
Hashes for nismod_snail-0.3.2-cp38-cp38-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9a0f4dc0b80cafa2804d650d04ff6d1098c485fac8567714c849e1fedcd2db27 |
|
MD5 | e7a83a1679e28544c9cd7ce92c4f7026 |
|
BLAKE2b-256 | 78546c7483f2ba960f49457b0e78c66a8ba1c6aa8e1715a2014480bd09cc9e26 |
Hashes for nismod_snail-0.3.2-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ccda9353358b5e4a16b8a3f24a11e6c8de212ca9d07521f74bfa515bfb67c912 |
|
MD5 | ebcba6606527fca94d782cbb3aef1fda |
|
BLAKE2b-256 | da8e7f05bb2ba0fdda635a89d5c1a706e270c6df2ccb2e1cb32e7c0be3bc2d6b |
Hashes for nismod_snail-0.3.2-cp38-cp38-macosx_10_9_universal2.macosx_10_9_x86_64.macosx_11_0_arm64.macosx_11_0_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c5937de63d21e5706a4ef555c45d916bd890a85cb21b556a508cb19893467dc2 |
|
MD5 | 90408fcedac1743e6d5f9963af6b2b7b |
|
BLAKE2b-256 | 5c3c6cc3c51ece35e21446471ff7394cd479d25793a7f6a2b91fdf87a89a53fd |