Skip to main content

Gridit

Tests Codcov DOI

Description

Gridit provides spatial tools to translate raster or vector geometry data to regular grids.

Installation

This package primarily depends on NumPy and SciPy, and has several optional dependencies.

Pip can be used to install all optional dependencies:

$ pip install gridit[optional]

Or from a clone of this repository, create an "editable" install:

$ pip install -e .[optional]

Testing

Run pytest -v.

Examples

Python

>>> import matplotlib.pyplot as plt  # optional
>>> from gridit import Grid

>>> grid = Grid.from_vector("tests/data/Mana_polygons.shp", 100)
>>> print(grid)
<Grid: resolution=100.0, shape=(24, 18), top_left=(1748600.0, 5451200.0) />

>>> ar_vec = grid.array_from_vector("tests/data/Mana_polygons.shp", "K_m_d")
>>> plt.imshow(ar_vec)
<matplotlib.image.AxesImage at 0x7fb6c7dacf10>

>>> ar_rast = grid.array_from_raster("tests/data/Mana.tif")
>>> plt.imshow(ar_rast)
<matplotlib.image.AxesImage at 0x7fb6bc4ad6d0>

Command line

Grid and array from vector, write PNG image and shapefile grid:

$ gridit --grid-from-vector tests/data/Mana_polygons.shp --resolution 100 \
    --array-from-vector tests/data/Mana_polygons.shp \
    --array-from-vector-attribute=K_m_d \
    --write-image /tmp/Mana_Kmd.png \
    --write-vector /tmp/Mana_Kmd.shp

Grid from bounding box, array from raster, write GeoTIFF raster:

$ gridit --grid-from-bbox 1748600 5448800 1750400 5451200 --resolution 100 \
    --array-from-raster tests/data/Mana.tif \
    --write-raster /tmp/Mana_100m.tif

Grid from vector, array from netCDF, write text array file for each time stat:

$ gridit --grid-from-vector tests/data/waitaku2.shp --resolution 250 \
    --array-from-vector tests/data/waitaku2.shp \
    --array-from-vector-attribute rid \
    --array-from-netcdf tests/data/waitaku2.nc:rid:myvar:0 \
    --time-stats "quantile(0.75),max" \
    --write-text /tmp/waitaku2_cat.ref

Grid from MODFLOW, array from vector, write text array file:

$ gridit --grid-from-modflow tests/data/modflow/mfsim.nam:h6 \
    --array-from-vector tests/data/waitaku2.shp \
    --array-from-vector-attribute rid \
    --write-text /tmp/waitaku2_rid.txt

See other options with:

$ gridit -h

Funding

Funding for the development of gridit has been provided by New Zealand Strategic Science Investment Fund as part of GNS Science’s (https://www.gns.cri.nz/) Groundwater Research Programme.

Release files for gridit 0.9

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

Source distribution (sdist)

Source distribution for gridit 0.9
File Size Uploaded
gridit-0.9.tar.gz 782.4 kB Details

Built distribution (wheel)

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

Total release size: 833.2 kB

Release files / gridit-0.9.tar.gz

Download URL gridit-0.9.tar.gz
Size 782.4 kB
Tags Source
SHA-256 checksum
How to use checksums
847eb3bbc8ccd82d4dad907937c91ebc98ffc381d30100e1d07e67d67399c617
BLAKE2b-256 checksum
How to use checksums
eecbba93b82044e80f153ad65d88eedcaccb263ccccc53f9f7dcd1e06d5846b6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Release files / gridit-0.9-py3-none-any.whl

Download URL gridit-0.9-py3-none-any.whl
Size 50.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b74ee8740b32c73b481f0de4267ab268bdc396770ead937a1fc9ef2ba99af60e
BLAKE2b-256 checksum
How to use checksums
0a05e22633667e1d449534ec18e7931da288dd978c3d33daa2dc2365a492a3f4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Release history Release notifications | RSS feed

This release

0.9 This release

2 release files

0.8

2 release files

0.7

2 release files

0.6

2 release files

0.5

2 release files

0.4

2 release files

0.3

2 release files

0.2

2 release files

0.1

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