Skip to main content

DOI PyPI Conda Version Test Documentation Status

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 DataArray using the rioxarray open_rasterio method. The API is wrapped with a Basic Model Interface (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.

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. After cloning or downloading the bmi-geotiff repository, 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 in the xarray documentation.

Start a Python session and import the GeoTiff class:

>>> from bmi_geotiff import GeoTiff

For convenience, let's use a test image from the rasterio project:

>>> url = "https://github.com/rasterio/rasterio/raw/main/tests/data/RGB.byte.tif"

Make an instance of GeoTiff with this URL:

>>> 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:

>>> 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:

>>> 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 method.

>>> import matplotlib.pyplot as plt
>>> g.da.plot.imshow()
>>> plt.show()

Example GeoTiff display through xarray.

For examples with more detail, see the Jupyter Notebooks and Python scripts included in the examples directory of the bmi-geotiff repository.

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

Credits

Project lead

  • Mark Piper

Acknowledgments

This work is supported by the U.S. National Science Foundation under Award No. 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.

Metadata

Release files for bmi-geotiff 0.4.0

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

Source distribution (sdist)

Source distribution for bmi-geotiff 0.4.0
File Size Uploaded Provenance Actions
bmi_geotiff-0.4.0.tar.gz 2.7 MB Without provenance Details for bmi_geotiff-0.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for bmi-geotiff 0.4.0
File Interpreter ABI Platform Actions
bmi_geotiff-0.4.0-py3-none-any.whl Python 3 none any Details for bmi_geotiff-0.4.0-py3-none-any.whl

Total release size: 2.7 MB

Release files / bmi_geotiff-0.4.0.tar.gz

Download URL bmi_geotiff-0.4.0.tar.gz
Size 2.7 MB
Tags Source
SHA-256 checksum
How to use checksums
7577d5daaddba1a0fbe31a8089f11d116932813f69f99542119a7962026b8668
BLAKE2b-256 checksum
How to use checksums
76573cf5fc2448a895aa94f4426820e4abf9b54b2ab4a3e72ea46a5b4732652b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Release files / bmi_geotiff-0.4.0-py3-none-any.whl

Download URL bmi_geotiff-0.4.0-py3-none-any.whl
Size 10.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7c9a70b5390174a6b602962b36fc905687fb32d776dedf64039ba4cf41d202d7
BLAKE2b-256 checksum
How to use checksums
707aee543b9f6e4322ca6c29a4ea680cfcf81fec8e8b9252a8f67e588cbb70fd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Security for bmi-geotiff 0.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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