Geography component¶
Every Field carries a geography component that describes
the horizontal spatial coordinate system of the field. The geography component is accessible via
the geography attribute of a field and is represented by a subclass of
GeographyBase.
>>> import earthkit.data as ekd
>>> field = ekd.from_source("sample", "test.grib").to_fieldlist()[0]
>>> field.geography.shape
(19, 36)
>>> field.geography.area()
(70, -20, 35, 40)
>>> field.geography.grid_type()
'regular_ll'
The same information is available through the generic get()
interface using the "geography." prefix:
>>> field.get("geography.area")
(70, -20, 35, 40)
>>> field.get("geography.shape")
(19, 36)
The geography component is immutable. Use the
set() method (or
set() on the field) to derive a modified copy.
When changing the grid it is typically necessary to supply new field values to match the
new grid shape:
>>> import numpy as np
>>> values = np.random.rand(19, 36)
>>> new_field = field.set({"geography.grid_spec": [10, 10], "values": values})
>>> new_field.geography.area()
(90.0, 0, -90.0, 360.0)
Geography types¶
The appropriate geography subclass is determined automatically from the data:
LatLonGeography — irregular or curvilinear lat/lon grid where every point has an explicit latitude and longitude.
MeshedLatLonGeography — regular lat/lon grid defined by distinct (1-D) latitude and longitude arrays that form a full Cartesian mesh.
GridsSpecBasedGeography — grid defined by an eckit-geo grid specification string or dictionary (requires optional eckit-geo grid support).
EmptyGeography — placeholder used when no coordinate information is available.
Accessing geography information¶
All geography keys are accessible through get() with the
"geography." prefix, and can therefore be used in
sel(),
order_by(), and
metadata().
Key |
Description |
|---|---|
|
Array of latitude values for every grid point. |
|
Array of longitude values for every grid point. |
|
1-D array of unique latitude values for regular grids, or |
|
1-D array of unique longitude values for regular grids, or |
|
Array of x-coordinates in the native CRS. |
|
Array of y-coordinates in the native CRS. |
|
Grid shape as a tuple of integers (e.g. |
|
|
|
|
|
Bounding box as a |
|
String identifying the grid type (e.g. |
|
Grid specification. Can be used to construct a new geography of the same type. |
|
Grid definition understood by eckit-geo (when grid support is available). |
|
A hashable identifier that is the same for two fields sharing an identical grid. |