gis

Geospatial logic.

Functions

geolatlon2swiss(lon, lat)

Convert from geolatlon to swiss coordinates.

get_grid(geo)

Get grid parameters for a given field.

rot2geolatlon(grid)

Compute geographical lat lon values for a rotated lat lon grid.

vref_rot2geolatlon(u, v)

Apply coordinate rotation to vector field.

Classes

RotLatLonGrid(rlon, rlat, north_pole_lon, ...)

Class representing a rotated lat lon grid.

class meteodatalab.operators.gis.RotLatLonGrid(rlon: DataArray, rlat: DataArray, north_pole_lon: float, north_pole_lat: float)[source]

Class representing a rotated lat lon grid.

rlon

longitude values in degrees of the grid points in the rotated lat lon CRS.

Type:

xr.DataArray

rlat

latitude values in degrees of the grid points in the rotated lat lon CRS.

Type:

xr.DataArray

north_pole_lon

longitude of the rotated north pole in degrees.

Type:

float

north_pole_lat

latitude of the rotated north pole in degrees.

Type:

float

meteodatalab.operators.gis.geolatlon2swiss(lon: DataArray, lat: DataArray) tuple[DataArray, DataArray][source]

Convert from geolatlon to swiss coordinates.

Parameters:
  • lon (xarray.DataArray) – longitude coordinates in the geolatlon CRS.

  • lat (xarray.DataArray) – latitude coordinates in the geolatlon CRS.

Returns:

x and y coordinates in the Swiss LV03 coordinate system.

Return type:

tuple[xarray.DataArray, xarray.DataArray]

Notes

Approximate formula published by swisstopo, precision in the order of 1 meter

meteodatalab.operators.gis.get_grid(geo: Mapping[str, Any]) RotLatLonGrid[source]

Get grid parameters for a given field.

Only fields defined on regular grids in rotlatlon coordinates, without rotation nor flipped axes are supported.

Parameters:

geo (Mapping[str, Any]) – Grib keys related to the geography of the field.

Raises:

ValueError – if the field does not fulfill the conditions above.

Returns:

object representing the rotated lat lon grid.

Return type:

RotLatLonGrid

meteodatalab.operators.gis.rot2geolatlon(grid: RotLatLonGrid) tuple[DataArray, DataArray][source]

Compute geographical lat lon values for a rotated lat lon grid.

Parameters:

grid (RotLatLonGrid) – object representing the rotated lat lon grid.

Returns:

tuple of longitudes and latitudes of the grid points in the geographical lat lon CRS.

Return type:

tuple[xarray.DataArray, xarray.DataArray]

meteodatalab.operators.gis.vref_rot2geolatlon(u: DataArray, v: DataArray) tuple[DataArray, DataArray][source]

Apply coordinate rotation to vector field.

When converting from rotated lat lon to geo lat lon, the orientation of the grid changes and vector fields for which the components are expressed in the grid unit vectors need to be realigned.

Note that this function does not perform any regridding.

Parameters:
  • u (xarray.DataArray) – x component of the vector field w.r.t. a rotated lat lon grid.

  • v (xarray.DataArray) – y component of the vector field w.r.t. a rotated lat lon grid.

Returns:

x and y components of the vector field w.r.t. the geo lat lon coords.

Return type:

tuple[xarray.DataArray, xarray.DataArray]