Skip to main content

Spatial tools to translate raster or vector geometry data to regular grids

Project description

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.

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

gridit-0.8.tar.gz (779.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gridit-0.8-py3-none-any.whl (48.3 kB view details)

Uploaded Python 3

File details

Details for the file gridit-0.8.tar.gz.

File metadata

  • Download URL: gridit-0.8.tar.gz
  • Upload date:
  • Size: 779.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for gridit-0.8.tar.gz
Algorithm Hash digest
SHA256 567065388bdfc2f164a6d77724003f12b74deb8523a98c9ac3959dbf8352f9db
MD5 cd8672b60279b22a95f005f9642f0a93
BLAKE2b-256 73d7214f9273144b75dff580c35eceda2e1772e3425a55804d450e4d6bed4036

See more details on using hashes here.

File details

Details for the file gridit-0.8-py3-none-any.whl.

File metadata

  • Download URL: gridit-0.8-py3-none-any.whl
  • Upload date:
  • Size: 48.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for gridit-0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 bd4767e5de97717f43f665510bacaada8b9011cce04f1823d860d94ac230c4c8
MD5 0257493fd3e83e05075b3e21f57ea9a7
BLAKE2b-256 b86c94ee6e938599a960a2a7cee0ef372beaba676c43f18fec7e351a0bb1b800

See more details on using hashes here.

Supported by

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