Skip to main content

Convenience functions for working with HDF4-EOS datasets

Project description

Python Tools for HDF4-EOS Format

Unfortunately, many important NASA datasets are still distributed as HDF4-EOS granules. These can be difficult or impossible to work with using GIS software. Even when opened using a library like GDAL, key spatial metadata are not accessed, resulting in the failure to fix the dataset's true spatial coordinates.

This small library may help you to avoid needing to install GDAL just to read the file. It is capable of reading an an HDF4 file (and HDF4-EOS files, in particular) and writing out a spatial dataset using rasterio, based on some strict assumptions about the file-level attributes; assumptions that are usually satisfied by an HDF4-EOS file.

The problems solved by py4eos include:

  • Reading an HDF4-EOS file without needing GDAL installed
  • Figuring out the coordinate reference system (CRS) and affine transformation of an HDF4-EOS granule
  • Converting an HDF4-EOS file to a more convenient raster format
  • Applying the scale and offset to an HDF4-EOS dataset's values to obtain true, geophysical values

Example Use

import earthaccess
import py4eos

# Download a MOD16A3GF granule
result = earthaccess.search_data(
    short_name = 'MOD16A3GF',
    temporal = ('2014-01-01', '2014-12-31'),
    bounding_box = (-106, 42, -103, 43))
earthaccess.download(result, TEST_DIR)

# Write the file to a GeoTIFF
hdf = py4eos.read_hdf4eos(granule_mod16a3)
hdf.to_rasterio('ET_500m', 'output_file.tiff')

Installation

The easiest way to install py4eos is using mamba (see installation instructions) or conda. This is the recommended way to install py4eos on Windows or Mac OS X:

mamba install py4eos

If the HDF4, zlib, and libjpeg libraries are already installed, then you can use pip on any system to install py4eos:

pip install py4eos

Installing dependencies on GNU/Linux:

  • On Ubuntu GNU/Linux: sudo apt install python3-dev libhdf4-dev

Running the test suite, from the root directory of the repository:

python -m pytest

Because data has to be downloaded as part of running the tests, they may fail the first time. Try running once more.

Acknowledgements

Development of the py4eos library was supported by a grant from NASA (80NSSC23K0864).

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

py4eos-0.5.0.tar.gz (8.7 kB view details)

Uploaded Source

Built Distribution

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

py4eos-0.5.0-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file py4eos-0.5.0.tar.gz.

File metadata

  • Download URL: py4eos-0.5.0.tar.gz
  • Upload date:
  • Size: 8.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.10.12

File hashes

Hashes for py4eos-0.5.0.tar.gz
Algorithm Hash digest
SHA256 0aadc8e4863a8647f4ccbef9d0c630b1c1f093c212adeb4981b445e5a295f36f
MD5 040d2dab9051568cb9e4ac2dfdf6b8f5
BLAKE2b-256 70c04e491094d3b6ecac742e3858a36e101f929448ddd2ae9e79236de55d3c49

See more details on using hashes here.

File details

Details for the file py4eos-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: py4eos-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 7.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.10.12

File hashes

Hashes for py4eos-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c7e13d6181f1f7b8edc443af0fa2f900e7255ffcab11093de883d8df1af11b16
MD5 3670a1088980056f1b7f81bf3b96746c
BLAKE2b-256 eb8d4f8f57a4f829fccecb3634d5d29ebbc2318f43988b298e07533ca098961b

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