2

I'm coming from Reading metadata in HDF5 file.

I have a HDF5 file with some radar information. I'd like to read this data and geospatial metadata contained in the file to produce a GeoTIFF. Using the accepted answer, I can read the metadata, but I'm not sure how to convert it to something that rasterio can understand to produce a valid CRS and transform that allow to georeference the field.

Right now, the metadata I can get from the HDF5 are these two dicts:

{'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'}


{'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)}

From the former I can easily obtain the CRS, but I don't fully understand the meaning of the parameters in the latter, although I'm pretty sure they implicitly define the transform.

How can this be used to produce a regular CRS and tranform understandable by rasterio?

1 Answer 1

1

You are correct, this information implies the transform and you will also want to fill out the profile so you can write the data to a GeoTIFF via rasterio.

You are going for a python dict that will look something like this:

{'affine': Affine(1.0000035, 0.0, x_corner, 0.0, -1.0000048, y_corner), 'count': 1, 'crs': CRS.from_string('+proj=stere +lat_0=90 +lon_0=0 +lat_ts=60 +a=6378.14 +b=6356.75 +x_0=0 y_0=0'})}), 'driver': 'GTiff', 'dtype': 'float32', 'height': 700, 'interleave': 'band', 'nodata': -9999.0, 'tiled': False, 'transform': (x_corner, 1.0, 0.0, y_corner.0, 0.0, -1.0000048), 'width': 765}

I've tried to fill those values as best I can guess from the data you posted - you'll need to figure out what to substitute for 'xcorner' and 'ycorner' though.

2
  • OK, thanks. But what are those "corners"? Aren't they those 8 numbers in 'geo_product_corners', which seem to be the coodinates of 4 corners?
    – Pythonist
    Commented Mar 14, 2021 at 10:18
  • Overall, I have serious concerns with the metadata in this file. This is data for the Netherlands. For what I can understand reading the proj4 string, it seems the projection is stereographical on top for the North pole... it makes no sense.
    – Pythonist
    Commented Mar 14, 2021 at 10:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.