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 an AttributeManager
object. It has items()
method.
To get map_projection
info, use this:
proj_info = dict(f['geographic']['map_projection'].attrs.items())
print(proj_info)
Output:
{'projection_indication': b'Y',
'projection_name': b'STEREOGRAPHIC',
'projection_proj4_params': b'+proj=stere +lat_0=90 +lon_0=0 +lat_ts=60 +a=6378.14 +b=6356.75 +x_0=0 y_0=0'}
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())
returns
{'geo_column_offset': array([0.], dtype=float32),
'geo_dim_pixel': b'KM,KM',
'geo_number_columns': array([700], dtype=int32),
'geo_number_rows': array([765], dtype=int32),
'geo_par_pixel': b'X,Y',
'geo_pixel_def': b'LU',
'geo_pixel_size_x': array([1.0000035], dtype=float32),
'geo_pixel_size_y': array([-1.0000048], dtype=float32),
'geo_product_corners': array([ 0., 49.362064, 0., 55.973602, 10.856453, 55.388973, 9.0093, 48.8953 ], dtype=float32),
'geo_row_offset': array([3649.982], dtype=float32)}
I used RAD_NL25_PCP_NA_201910281110.h5
file for testing.
Best Answer
I am currently in the same position as you. HDF5 is a great format, but you need to define and characterize it yourself. Python has a very handy module called h5py, which is quite straight-forward. It is dependent on numpy and the documentation shows you some examples how to query and store your arrays. HDF5 also supports heterogeneous datasets, thus it is all about how you define your container and dimension structure. At the last SciPy 2015 conference there was a very convincing talk about the future of HDF5 and Python.
You might also consider netCDF4, which uses hdf5 as backbone as well and has somewhat more support from the Earth-observation community. IMHO defining dimensions (e.g. x-axis for longitude, y-axis is latitude and so on) is actually easier with the netCDF syntax.