Skip to main content

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

Release files for py4eos 0.6.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 py4eos 0.6.0
File Size Uploaded
py4eos-0.6.0.tar.gz 8.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for py4eos 0.6.0
File Interpreter ABI Platform
py4eos-0.6.0-py3-none-any.whl Python 3 none any Details

Total release size: 16.4 kB

Release files / py4eos-0.6.0.tar.gz

Download URL py4eos-0.6.0.tar.gz
Size 8.7 kB
Tags Source
SHA-256 checksum
How to use checksums
2b17e232ca1db0117e3644e27ef375af3353541d6eaafd9ad15bdc467539adfb
BLAKE2b-256 checksum
How to use checksums
d3b2052f7aa3d19fc9da784c5a11420cd02de2245ebb325282d05f7d46e60a21
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.10.12

Release files / py4eos-0.6.0-py3-none-any.whl

Download URL py4eos-0.6.0-py3-none-any.whl
Size 7.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1ba39d1dc2f7a99fd60eaf57fe2828830a5381e37c6e048e24e8e1529570b1ce
BLAKE2b-256 checksum
How to use checksums
acd7e5719c34f93b12e41faf1f2903ac323775cf4aff56d5910b4a2108d27f41
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.10.12

Release history Release notifications | RSS feed

This release

0.6.0 This release

2 release files

0.5.0

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.1

2 release files

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