Converting GRIB to GeoTIFFΒΆ
[1]:
import earthkit.data as ekd
ds = ekd.from_source("sample", "test.grib")
ds.to_fieldlist().ls()
[1]:
| parameter.variable | time.valid_datetime | time.base_datetime | time.step | vertical.level | vertical.level_type | ensemble.member | geography.grid_type | |
|---|---|---|---|---|---|---|---|---|
| 0 | 2t | 2020-05-13 12:00:00 | 2020-05-13 12:00:00 | 0 days | 0 | surface | 0 | regular_ll |
| 1 | msl | 2020-05-13 12:00:00 | 2020-05-13 12:00:00 | 0 days | 0 | surface | 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.to_fieldlist().ls()
[3]:
| parameter.variable | time.valid_datetime | time.base_datetime | time.step | vertical.level | vertical.level_type | ensemble.member | geography.grid_type | |
|---|---|---|---|---|---|---|---|---|
| 0 | 2 metre temperature | None | None | None | None | unknown | None | None |
| 1 | Mean sea level pressure | None | None | None | None | unknown | None | None |
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.
[ ]: