semantique.processor.utils.parse_extent

Contents

semantique.processor.utils.parse_extent#

semantique.processor.utils.parse_extent(spatial_extent, temporal_extent, spatial_resolution, temporal_resolution=None, crs=None, tz=None, trim=True)[source]#

Parse the spatial and temporal extent into a spatio-temporal array.

Internally the query processor uses a multi-dimensional array to represent the spatio-temporal extent of the query. This is an xarray.DataArray and forms the base template for all arrays that are retrieved from the mapping during query processing.

Parameters:
  • spatial_extent (SpatialExtent) – Spatial extent.

  • temporal_extent (TemporalExtent) – Temporal extent.

  • spatial_resolution (list) – Spatial resolution of the array. Should be given as a list in the format [y, x], where y is the cell size along the y-axis, x is the cell size along the x-axis, and both are given as int or float value expressed in the units of the CRS. These values should include the direction of the axes. For most CRSs, the y-axis has a negative direction, and hence the cell size along the y-axis is given as a negative number.

  • temporal_resolution (str or pandas.tseries.offsets.DateOffset) – Temporal resolution of the array. Can be given as offset alias as defined in pandas, e.g. “D” for a daily frequency. These aliases can have multiples, e.g. “5D”. If None, only the start and end instants of the extent will be temporal coordinates in the array.

  • crs (optional) – Coordinate reference system in which the spatial coordinates of the array should be expressed. Can be given as any object understood by the initializer of pyproj.crs.CRS. This includes pyproj.crs.CRS objects themselves, as well as EPSG codes and WKT strings. If None, the CRS of the provided spatial extent is used.

  • tz (optional) – Timezone in which the temporal coordinates of the array should be expressed. Can be given as str referring to the name of a time zone in the tz database, or as instance of any class inheriting from datetime.tzinfo. If None, the timezone of the provided temporal extent is used.

  • trim (bool) – Should the array be trimmed before returning? Trimming means that dimension coordinates for which all values are missing are removed from the array. The spatial dimension is treated differently, by trimming it only at the edges, and thus maintaining its regularity.

Returns:

xarray.DataArray – A two-dimensional array with a spatial and temporal dimension. The spatial dimension is a stacked dimension with each coordinate value being a tuple of the x and y coordinate of the corresponding cell.