gridit


Namegridit JSON
Version 0.5 PyPI version JSON
download
home_page
SummarySpatial tools to translate raster or vector geometry data to regular grids
upload_time2023-12-06 22:34:52
maintainer
docs_urlNone
author
requires_python>=3.8
licenseBSD 3-Clause
keywords rasterize grid regular grid
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Gridit

[![Tests](https://github.com/mwtoews/gridit/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/mwtoews/gridit/actions/workflows/tests.yml)
[![Codcov](https://codecov.io/gh/mwtoews/gridit/branch/main/graph/badge.svg)](https://codecov.io/gh/mwtoews/gridit)
[![DOI](https://zenodo.org/badge/530041277.svg)](https://zenodo.org/badge/latestdoi/530041277)

## 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:
```bash
$ pip install gridit[optional]
```

Or from a clone of this repository, create an "editable" install:
```bash
$ pip install -e .[optional]
```

### Testing

Run `pytest -v`.

## Examples

### Python

```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:
```bash
$ 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:
```bash
$ 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:
```bash
$ 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:
```bash
$ 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:
```bash
$ 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.

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "gridit",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "rasterize,grid,regular grid",
    "author": "",
    "author_email": "Mike Taves <mwtoews@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/ff/8d/914dd709675dcdcf37abb15a84f39f77c97505ed0ed75fc51b23a24e5719/gridit-0.5.tar.gz",
    "platform": null,
    "description": "# Gridit\n\n[![Tests](https://github.com/mwtoews/gridit/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/mwtoews/gridit/actions/workflows/tests.yml)\n[![Codcov](https://codecov.io/gh/mwtoews/gridit/branch/main/graph/badge.svg)](https://codecov.io/gh/mwtoews/gridit)\n[![DOI](https://zenodo.org/badge/530041277.svg)](https://zenodo.org/badge/latestdoi/530041277)\n\n## Description\n\nGridit provides spatial tools to translate raster or vector geometry data to regular grids.\n\n## Installation\n\nThis package primarily depends on NumPy and SciPy, and has several optional dependencies.\n\nPip can be used to install all optional dependencies:\n```bash\n$ pip install gridit[optional]\n```\n\nOr from a clone of this repository, create an \"editable\" install:\n```bash\n$ pip install -e .[optional]\n```\n\n### Testing\n\nRun `pytest -v`.\n\n## Examples\n\n### Python\n\n```python\n>>> import matplotlib.pyplot as plt  # optional\n>>> from gridit import Grid\n\n>>> grid = Grid.from_vector(\"tests/data/Mana_polygons.shp\", 100)\n>>> print(grid)\n<Grid: resolution=100.0, shape=(24, 18), top_left=(1748600.0, 5451200.0) />\n\n>>> ar_vec = grid.array_from_vector(\"tests/data/Mana_polygons.shp\", \"K_m_d\")\n>>> plt.imshow(ar_vec)\n<matplotlib.image.AxesImage at 0x7fb6c7dacf10>\n\n>>> ar_rast = grid.array_from_raster(\"tests/data/Mana.tif\")\n>>> plt.imshow(ar_rast)\n<matplotlib.image.AxesImage at 0x7fb6bc4ad6d0>\n```\n\n### Command line\n\nGrid and array from vector, write PNG image and shapefile grid:\n```bash\n$ gridit --grid-from-vector tests/data/Mana_polygons.shp --resolution 100 \\\n    --array-from-vector tests/data/Mana_polygons.shp \\\n    --array-from-vector-attribute=K_m_d \\\n    --write-image /tmp/Mana_Kmd.png \\\n    --write-vector /tmp/Mana_Kmd.shp\n```\n\nGrid from bounding box, array from raster, write GeoTIFF raster:\n```bash\n$ gridit --grid-from-bbox 1748600 5448800 1750400 5451200 --resolution 100 \\\n    --array-from-raster tests/data/Mana.tif \\\n    --write-raster /tmp/Mana_100m.tif\n```\n\nGrid from vector, array from netCDF, write text array file for each time stat:\n```bash\n$ gridit --grid-from-vector tests/data/waitaku2.shp --resolution 250 \\\n    --array-from-vector tests/data/waitaku2.shp \\\n    --array-from-vector-attribute rid \\\n    --array-from-netcdf tests/data/waitaku2.nc:rid:myvar:0 \\\n    --time-stats \"quantile(0.75),max\" \\\n    --write-text /tmp/waitaku2_cat.ref\n```\n\nGrid from MODFLOW, array from vector, write text array file:\n```bash\n$ gridit --grid-from-modflow tests/data/modflow/mfsim.nam:h6 \\\n    --array-from-vector tests/data/waitaku2.shp \\\n    --array-from-vector-attribute rid \\\n    --write-text /tmp/waitaku2_rid.txt\n```\n\nSee other options with:\n```bash\n$ gridit -h\n```\n\n## Funding\nFunding for the development of gridit has been provided by New Zealand Strategic Science Investment Fund as part of GNS Science\u2019s (https://www.gns.cri.nz/) Groundwater Research Programme.\n",
    "bugtrack_url": null,
    "license": "BSD 3-Clause",
    "summary": "Spatial tools to translate raster or vector geometry data to regular grids",
    "version": "0.5",
    "project_urls": {
        "Repository": "https://github.com/mwtoews/gridit"
    },
    "split_keywords": [
        "rasterize",
        "grid",
        "regular grid"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "43a0119f59ffb00dc78651d9ea7a44d9f73c9a4bc95e08ddc60874e02bd13c3f",
                "md5": "81a0ff14bb34cd6374bc0f0480e2eb5b",
                "sha256": "7b28319a848f0a2d83b524fdee215aaa57ea31a6b508c252c55199ec6edc9bf7"
            },
            "downloads": -1,
            "filename": "gridit-0.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "81a0ff14bb34cd6374bc0f0480e2eb5b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 42851,
            "upload_time": "2023-12-06T22:34:48",
            "upload_time_iso_8601": "2023-12-06T22:34:48.373221Z",
            "url": "https://files.pythonhosted.org/packages/43/a0/119f59ffb00dc78651d9ea7a44d9f73c9a4bc95e08ddc60874e02bd13c3f/gridit-0.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ff8d914dd709675dcdcf37abb15a84f39f77c97505ed0ed75fc51b23a24e5719",
                "md5": "8c2b929005039699e75e61e05a70dc6e",
                "sha256": "5a266dfe6fff7f1ca95d49a80db14aae445dbc969202b9f4af5b076f80522e9c"
            },
            "downloads": -1,
            "filename": "gridit-0.5.tar.gz",
            "has_sig": false,
            "md5_digest": "8c2b929005039699e75e61e05a70dc6e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 634997,
            "upload_time": "2023-12-06T22:34:52",
            "upload_time_iso_8601": "2023-12-06T22:34:52.995038Z",
            "url": "https://files.pythonhosted.org/packages/ff/8d/914dd709675dcdcf37abb15a84f39f77c97505ed0ed75fc51b23a24e5719/gridit-0.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-12-06 22:34:52",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "mwtoews",
    "github_project": "gridit",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "gridit"
}
        
Elapsed time: 0.20573s