I have a HDF5 file with a field of radar observations. I'd like to read this data and produce a GeoTiff that contains the spatial metadata. I can access the data, but I can't access the geographical metadata (which I assume it must be inside the file).
The file is one of these that can be freely downloaded here.
The code I have is:
import h5py
filename = 'RAD_NL25_PCP_NA_202103111340.h5'
f = h5py.File(filename, 'r')
data = f['image1']['image_data'][:,:]
This works to get a numpy array with the data. Now, the metadata seems to be in the group f['geographic']['map_projection']
but this seems to be an empty without dataset.
Do you know how to inspect this file to get the metadata, or how to assert that it is really an empty group?
Best Answer
f['geographic']['map_projection']
is a group. It returns this:<HDF5 group "/geographic/map_projection" (0 members)>
.0 members
means it is really an empty group.But a group has attributes. You can get atrributes using
attrs
which gives you anAttributeManager
object. It hasitems()
method.To get
map_projection
info, use this:Output:
You can use the script in this post to see all structure of the h5 file, then use
attrs.items()
for other groups/datasets to get other metadata.For example:
dict(f['geographic'].attrs.items())
returnsI used
RAD_NL25_PCP_NA_201910281110.h5
file for testing.