Package: bmi-geotiff
bmi-geotiffAccess data (and metadata) from a GeoTIFF file through an API or a BMI.Thebmi-geotifflibrary accepts a filepath or an URL to a GeoTIFF file.
Data are loaded into anxarrayDataArrayusing therioxarrayopen_rasteriomethod.
The API is wrapped with aBasic 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 itsdocumentation.InstallationInstall the latest stable release ofbmi-geotiffwithpip:pip install bmi-geotiffor withconda:conda install -c conda-forge bmi-geotiffAlternately,
thebmi-geotifflibrary 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 aconda environment.
After cloning or downloading thebmi-geotiffrepository,
change into the repository directory
and set up a conda environment with the included environment file:conda env create --file environment.ymlThen build and installbmi-geotifffrom source withpip install -e .ExamplesA brief example of using thebmi-geotiffAPI is given in the following steps.
The example is derived from asimilar examplein the xarray documentation.Start a Python session and import theGeoTiffclass:>>>frombmi_geotiffimportGeoTiffFor convenience,
let's use a test image from therasterioproject:>>>url="https://github.com/rasterio/rasterio/raw/main/tests/data/RGB.byte.tif"Make an instance ofGeoTiffwith 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 xarrayDataArray, which can be accessed through thedaproperty:>>>g.da<xarray.DataArray(band:3,y:718,x:791)>[1703814valueswithdtype=uint8]Coordinates:*band(band)int64123*x(x)float641.021e+051.024e+05...3.389e+053.392e+05*y(y)float642.827e+062.826e+06...2.612e+062.612e+06spatial_refint640Attributes:STATISTICS_MAXIMUM:255STATISTICS_MEAN:29.947726688477STATISTICS_MINIMUM:0STATISTICS_STDDEV:52.340921626611_FillValue:0.0scale_factor:1.0add_offset:0.0units:metreNote that coordinate reference system information is stored
in thespatial_refnon-dimensional coordinate:>>>g.da.spatial_ref<xarray.DataArray'spatial_ref'()>array(0)Coordinates:spatial_refint640Attributes:crs_wkt:PROJCS["WGS 84 / UTM zone 18N",GEOGCS[...semi_major_axis:6378137.0semi_minor_axis:6356752.314245179inverse_flattening:298.257223563reference_ellipsoid_name:WGS84longitude_of_prime_meridian:0.0prime_meridian_name:Greenwichgeographic_crs_name:WGS84horizontal_datum_name:WorldGeodeticSystem1984projected_crs_name:WGS84/UTMzone18Ngrid_mapping_name:transverse_mercatorlatitude_of_projection_origin:0.0longitude_of_central_meridian:-75.0false_easting:500000.0false_northing:0.0scale_factor_at_central_meridian:0.9996spatial_ref:PROJCS["WGS 84 / UTM zone 18N",GEOGCS[...GeoTransform:101985.0300.03792667509480.02826915...Display the image with thexarray.plot.imshowmethod.>>>importmatplotlib.pyplotasplt>>>g.da.plot.imshow()>>>plt.show()For examples with more detail,
see the Jupyter Notebooks and Python scripts
included in theexamplesdirectory
of thebmi-geotiffrepository.Documentation forbmi-geotiffis available athttps://bmi-geotiff.readthedocs.io.CreditsProject leadMark PiperAcknowledgmentsThis work is supported by the National Science Foundation
under Award No.1831623,Community Facility Support: The Community Surface Dynamics Modeling System (CSDMS).MIT LicenseCopyright (c) 2021 Community Surface Dynamics Modeling SystemPermission 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.