bmi-geotiff


Namebmi-geotiff JSON
Version 0.3.3 PyPI version JSON
download
home_pageNone
SummaryAccess data and metadata in a GeoTIFF file through an API or a BMI
upload_time2024-08-18 01:38:29
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseMIT License
keywords bmi geotiff raster data
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.8327418.svg)](https://doi.org/10.5281/zenodo.8327418)
[![PyPI](https://img.shields.io/pypi/v/bmi-geotiff)](https://pypi.org/project/bmi-geotiff)
[![Conda Version](https://img.shields.io/conda/vn/conda-forge/bmi-geotiff.svg)](https://anaconda.org/conda-forge/bmi-geotiff)
[![Test](https://github.com/csdms/bmi-geotiff/actions/workflows/test.yml/badge.svg)](https://github.com/csdms/bmi-geotiff/actions/workflows/test.yml)
[![Documentation Status](https://readthedocs.org/projects/bmi-geotiff/badge/?version=latest)](https://bmi-geotiff.readthedocs.io/en/latest/?badge=latest)

# bmi-geotiff

Access data (and metadata) from a GeoTIFF file through an API or a BMI.

The *bmi-geotiff* library accepts a filepath or an URL to a GeoTIFF file.
Data are loaded into an
[xarray](http://xarray.pydata.org/en/stable/)
[DataArray](http://xarray.pydata.org/en/stable/api.html#dataarray)
using the [rioxarray](https://corteva.github.io/rioxarray/stable/index.html)
[open_rasterio](https://corteva.github.io/rioxarray/stable/rioxarray.html#rioxarray.open_rasterio) method.
The API is wrapped with a
[Basic Model Interface](https://bmi.readthedocs.io) (BMI),
which provides a standard set of functions for coupling with data or models
that also expose a BMI.
More information on the BMI can found in its
[documentation](https://bmi.readthedocs.io).

## Installation

Install the latest stable release of *bmi-geotiff* with `pip`:
```
pip install bmi-geotiff
```
or with `conda`:
```
conda install -c conda-forge bmi-geotiff
```

Alternately,
the *bmi-geotiff* library can be built and installed from source.
The library uses several other open source libraries,
so a convenient way of building and installing it is within a
[conda environment](https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html).
After cloning or downloading the *bmi-geotiff*
[repository](https://github.com/csdms/bmi-geotiff),
change into the repository directory
and set up a conda environment with the included environment file:
```
conda env create --file environment.yml
```
Then build and install *bmi-geotiff* from source with
```
pip install -e .
```

## Examples

A brief example of using the *bmi-geotiff* API is given in the following steps.
The example is derived from a [similar example](http://xarray.pydata.org/en/stable/examples/visualization_gallery.html#imshow()-and-rasterio-map-projections) in the xarray documentation.

Start a Python session and import the `GeoTiff` class:
```python
>>> from bmi_geotiff import GeoTiff
```

For convenience,
let's use a test image from the [rasterio](https://rasterio.readthedocs.io) project:
```python
>>> url = "https://github.com/rasterio/rasterio/raw/main/tests/data/RGB.byte.tif"
```

Make an instance of `GeoTiff` with this URL:
```python
>>> g = GeoTiff(url)
```
This step might take a few moments as the data are pulled from GitHub.

The data have been loaded into an xarray `DataArray`, which can be accessed through the `da` property:
```python
>>> g.da
<xarray.DataArray (band: 3, y: 718, x: 791)>
[1703814 values with dtype=uint8]
Coordinates:
  * band         (band) int64 1 2 3
  * x            (x) float64 1.021e+05 1.024e+05 ... 3.389e+05 3.392e+05
  * y            (y) float64 2.827e+06 2.826e+06 ... 2.612e+06 2.612e+06
    spatial_ref  int64 0
Attributes:
    STATISTICS_MAXIMUM:  255
    STATISTICS_MEAN:     29.947726688477
    STATISTICS_MINIMUM:  0
    STATISTICS_STDDEV:   52.340921626611
    _FillValue:          0.0
    scale_factor:        1.0
    add_offset:          0.0
    units:               metre
```

Note that coordinate reference system information is stored
in the `spatial_ref` non-dimensional coordinate:
```python
>>> g.da.spatial_ref
<xarray.DataArray 'spatial_ref' ()>
array(0)
Coordinates:
    spatial_ref  int64 0
Attributes:
    crs_wkt:                           PROJCS["WGS 84 / UTM zone 18N",GEOGCS[...
    semi_major_axis:                   6378137.0
    semi_minor_axis:                   6356752.314245179
    inverse_flattening:                298.257223563
    reference_ellipsoid_name:          WGS 84
    longitude_of_prime_meridian:       0.0
    prime_meridian_name:               Greenwich
    geographic_crs_name:               WGS 84
    horizontal_datum_name:             World Geodetic System 1984
    projected_crs_name:                WGS 84 / UTM zone 18N
    grid_mapping_name:                 transverse_mercator
    latitude_of_projection_origin:     0.0
    longitude_of_central_meridian:     -75.0
    false_easting:                     500000.0
    false_northing:                    0.0
    scale_factor_at_central_meridian:  0.9996
    spatial_ref:                       PROJCS["WGS 84 / UTM zone 18N",GEOGCS[...
    GeoTransform:                      101985.0 300.0379266750948 0.0 2826915...
```

Display the image with the [xarray.plot.imshow](http://xarray.pydata.org/en/stable/generated/xarray.plot.imshow.html) method.
```python
>>> import matplotlib.pyplot as plt
>>> g.da.plot.imshow()
>>> plt.show()
```

![Example GeoTiff display through *xarray*.](./examples/example-rgb.png)

For examples with more detail,
see the Jupyter Notebooks and Python scripts
included in the [examples](https://github.com/csdms/bmi-geotiff/tree/main/examples) directory
of the *bmi-geotiff* repository.

Documentation for *bmi-geotiff*
is available at https://bmi-geotiff.readthedocs.io.

Credits
=======

Project lead
------------

* Mark Piper

Acknowledgments
---------------

This work is supported by the National Science Foundation
under Award No. [1831623](https://nsf.gov/awardsearch/showAward?AWD_ID=1831623),
*Community Facility Support: The Community Surface Dynamics Modeling System (CSDMS)*.

MIT License
-----------

Copyright (c) 2021 Community Surface Dynamics Modeling System

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "bmi-geotiff",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "bmi, geotiff, raster, data",
    "author": null,
    "author_email": "Mark Piper <mark.piper@colorado.edu>",
    "download_url": "https://files.pythonhosted.org/packages/13/3d/f062f66e5d5539a83dfbca46e95693fe3ff21c09cae49653aab84874a8a9/bmi_geotiff-0.3.3.tar.gz",
    "platform": null,
    "description": "[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.8327418.svg)](https://doi.org/10.5281/zenodo.8327418)\n[![PyPI](https://img.shields.io/pypi/v/bmi-geotiff)](https://pypi.org/project/bmi-geotiff)\n[![Conda Version](https://img.shields.io/conda/vn/conda-forge/bmi-geotiff.svg)](https://anaconda.org/conda-forge/bmi-geotiff)\n[![Test](https://github.com/csdms/bmi-geotiff/actions/workflows/test.yml/badge.svg)](https://github.com/csdms/bmi-geotiff/actions/workflows/test.yml)\n[![Documentation Status](https://readthedocs.org/projects/bmi-geotiff/badge/?version=latest)](https://bmi-geotiff.readthedocs.io/en/latest/?badge=latest)\n\n# bmi-geotiff\n\nAccess data (and metadata) from a GeoTIFF file through an API or a BMI.\n\nThe *bmi-geotiff* library accepts a filepath or an URL to a GeoTIFF file.\nData are loaded into an\n[xarray](http://xarray.pydata.org/en/stable/)\n[DataArray](http://xarray.pydata.org/en/stable/api.html#dataarray)\nusing the [rioxarray](https://corteva.github.io/rioxarray/stable/index.html)\n[open_rasterio](https://corteva.github.io/rioxarray/stable/rioxarray.html#rioxarray.open_rasterio) method.\nThe API is wrapped with a\n[Basic Model Interface](https://bmi.readthedocs.io) (BMI),\nwhich provides a standard set of functions for coupling with data or models\nthat also expose a BMI.\nMore information on the BMI can found in its\n[documentation](https://bmi.readthedocs.io).\n\n## Installation\n\nInstall the latest stable release of *bmi-geotiff* with `pip`:\n```\npip install bmi-geotiff\n```\nor with `conda`:\n```\nconda install -c conda-forge bmi-geotiff\n```\n\nAlternately,\nthe *bmi-geotiff* library can be built and installed from source.\nThe library uses several other open source libraries,\nso a convenient way of building and installing it is within a\n[conda environment](https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html).\nAfter cloning or downloading the *bmi-geotiff*\n[repository](https://github.com/csdms/bmi-geotiff),\nchange into the repository directory\nand set up a conda environment with the included environment file:\n```\nconda env create --file environment.yml\n```\nThen build and install *bmi-geotiff* from source with\n```\npip install -e .\n```\n\n## Examples\n\nA brief example of using the *bmi-geotiff* API is given in the following steps.\nThe example is derived from a [similar example](http://xarray.pydata.org/en/stable/examples/visualization_gallery.html#imshow()-and-rasterio-map-projections) in the xarray documentation.\n\nStart a Python session and import the `GeoTiff` class:\n```python\n>>> from bmi_geotiff import GeoTiff\n```\n\nFor convenience,\nlet's use a test image from the [rasterio](https://rasterio.readthedocs.io) project:\n```python\n>>> url = \"https://github.com/rasterio/rasterio/raw/main/tests/data/RGB.byte.tif\"\n```\n\nMake an instance of `GeoTiff` with this URL:\n```python\n>>> g = GeoTiff(url)\n```\nThis step might take a few moments as the data are pulled from GitHub.\n\nThe data have been loaded into an xarray `DataArray`, which can be accessed through the `da` property:\n```python\n>>> g.da\n<xarray.DataArray (band: 3, y: 718, x: 791)>\n[1703814 values with dtype=uint8]\nCoordinates:\n  * band         (band) int64 1 2 3\n  * x            (x) float64 1.021e+05 1.024e+05 ... 3.389e+05 3.392e+05\n  * y            (y) float64 2.827e+06 2.826e+06 ... 2.612e+06 2.612e+06\n    spatial_ref  int64 0\nAttributes:\n    STATISTICS_MAXIMUM:  255\n    STATISTICS_MEAN:     29.947726688477\n    STATISTICS_MINIMUM:  0\n    STATISTICS_STDDEV:   52.340921626611\n    _FillValue:          0.0\n    scale_factor:        1.0\n    add_offset:          0.0\n    units:               metre\n```\n\nNote that coordinate reference system information is stored\nin the `spatial_ref` non-dimensional coordinate:\n```python\n>>> g.da.spatial_ref\n<xarray.DataArray 'spatial_ref' ()>\narray(0)\nCoordinates:\n    spatial_ref  int64 0\nAttributes:\n    crs_wkt:                           PROJCS[\"WGS 84 / UTM zone 18N\",GEOGCS[...\n    semi_major_axis:                   6378137.0\n    semi_minor_axis:                   6356752.314245179\n    inverse_flattening:                298.257223563\n    reference_ellipsoid_name:          WGS 84\n    longitude_of_prime_meridian:       0.0\n    prime_meridian_name:               Greenwich\n    geographic_crs_name:               WGS 84\n    horizontal_datum_name:             World Geodetic System 1984\n    projected_crs_name:                WGS 84 / UTM zone 18N\n    grid_mapping_name:                 transverse_mercator\n    latitude_of_projection_origin:     0.0\n    longitude_of_central_meridian:     -75.0\n    false_easting:                     500000.0\n    false_northing:                    0.0\n    scale_factor_at_central_meridian:  0.9996\n    spatial_ref:                       PROJCS[\"WGS 84 / UTM zone 18N\",GEOGCS[...\n    GeoTransform:                      101985.0 300.0379266750948 0.0 2826915...\n```\n\nDisplay the image with the [xarray.plot.imshow](http://xarray.pydata.org/en/stable/generated/xarray.plot.imshow.html) method.\n```python\n>>> import matplotlib.pyplot as plt\n>>> g.da.plot.imshow()\n>>> plt.show()\n```\n\n![Example GeoTiff display through *xarray*.](./examples/example-rgb.png)\n\nFor examples with more detail,\nsee the Jupyter Notebooks and Python scripts\nincluded in the [examples](https://github.com/csdms/bmi-geotiff/tree/main/examples) directory\nof the *bmi-geotiff* repository.\n\nDocumentation for *bmi-geotiff*\nis available at https://bmi-geotiff.readthedocs.io.\n\nCredits\n=======\n\nProject lead\n------------\n\n* Mark Piper\n\nAcknowledgments\n---------------\n\nThis work is supported by the National Science Foundation\nunder Award No. [1831623](https://nsf.gov/awardsearch/showAward?AWD_ID=1831623),\n*Community Facility Support: The Community Surface Dynamics Modeling System (CSDMS)*.\n\nMIT License\n-----------\n\nCopyright (c) 2021 Community Surface Dynamics Modeling System\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n",
    "bugtrack_url": null,
    "license": "MIT License",
    "summary": "Access data and metadata in a GeoTIFF file through an API or a BMI",
    "version": "0.3.3",
    "project_urls": {
        "Changelog": "https://github.com/csdms/bmi-geotiff/blob/main/CHANGES.md",
        "Documentation": "https://bmi-geotiff.readthedocs.io/",
        "Homepage": "https://csdms.colorado.edu",
        "Repository": "https://github.com/csdms/bmi-geotiff"
    },
    "split_keywords": [
        "bmi",
        " geotiff",
        " raster",
        " data"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "294ed949bbe43205d20bb2008c8c4fed84f1d01c48528ca3440a79071d6304db",
                "md5": "407189dde75f4b8f45b8650d2c1e4231",
                "sha256": "1a016d88746c31c2b376dc1f8d4c5d31108e637a6ebab4a6d3d1c8d3b1d35112"
            },
            "downloads": -1,
            "filename": "bmi_geotiff-0.3.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "407189dde75f4b8f45b8650d2c1e4231",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 10859,
            "upload_time": "2024-08-18T01:38:25",
            "upload_time_iso_8601": "2024-08-18T01:38:25.878353Z",
            "url": "https://files.pythonhosted.org/packages/29/4e/d949bbe43205d20bb2008c8c4fed84f1d01c48528ca3440a79071d6304db/bmi_geotiff-0.3.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "133df062f66e5d5539a83dfbca46e95693fe3ff21c09cae49653aab84874a8a9",
                "md5": "c627d3891e0261c754df1f65dae735db",
                "sha256": "2e2012ddbe3244bde370114c9fce7ad116e53310315f216d494f070adddf6d41"
            },
            "downloads": -1,
            "filename": "bmi_geotiff-0.3.3.tar.gz",
            "has_sig": false,
            "md5_digest": "c627d3891e0261c754df1f65dae735db",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 2723666,
            "upload_time": "2024-08-18T01:38:29",
            "upload_time_iso_8601": "2024-08-18T01:38:29.194628Z",
            "url": "https://files.pythonhosted.org/packages/13/3d/f062f66e5d5539a83dfbca46e95693fe3ff21c09cae49653aab84874a8a9/bmi_geotiff-0.3.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-18 01:38:29",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "csdms",
    "github_project": "bmi-geotiff",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "bmi-geotiff"
}
        
Elapsed time: 9.80844s