Converting GRIB to GeoTIFF

[1]:
import earthkit.data as ekd
ds = ekd.from_source("sample", "test.grib")
ds.ls()
[1]:
centre shortName typeOfLevel level dataDate dataTime stepRange dataType number gridType
0 ecmf 2t surface 0 20200513 1200 0 an 0 regular_ll
1 ecmf msl surface 0 20200513 1200 0 an 0 regular_ll

We use to_target() to write the GRIB fieldlist/field into a file. The encoder is automatically guessed from the target file suffix.

[2]:
ds.to_target("file", "_test.tiff")

Check the resulting GeoTIFF file.

[3]:
ds1 = ekd.from_source("file", "_test.tiff")
ds1.ls()
[3]:
variable band
0 2 metre temperature 1
1 Mean sea level pressure 2

Please note that to generate GeoTIFF the GRIB data is converted into Xarray internally. Right now the GeoTIFF output can only be generated if all the DataArrays in the Xarray are 2D.

[ ]: