zarr_convention_cs: GeoZarr "cs" convention

zarr_convention_csR Documentation

GeoZarr "cs" convention

Description

This class implements the GeoZarr "cs" (coordinate set) convention. The convention attaches a full coordinate system to a Zarr array by recording, for each dimension, the axis abbreviation and direction, one or more sets of coordinate values and their optional cell-boundary values, and, where applicable, the parametric formula and its terms needed to derive physical coordinates from stored index coordinates.

The convention is registered via the following CMO:

{
  "schema_url": "https://raw.githubusercontent.com/R-CF/zarr_convention_cs/main/schema.json",
  "spec_url":   "https://raw.githubusercontent.com/R-CF/zarr_convention_cs/main/README.md",
  "uuid":       "e4dbf0b7-7a00-4ce6-b23e-484292014ab4",
  "name":       "cs",
  "description": "Coordinate set convention for Zarr arrays"
}

The cs attribute written to the array metadata has the following structure (simplified):

{
  "cs": {
    "crs": [
      {
        "type": "compound" | "planar" | "vertical" | "temporal" | "undefined",
        "description: "optional text",
        "axes": {
          "<dimension_name>": {
            "abbreviation": "X",
            "direction":    "EAST",
            "coordinates":  [ { "unit": "degrees",
                                "values": { "regular": [0.0, 0.5] } } ]
          }
        }
      }
    ],
    "id": "Identifier of a compound CRS",
    "attributes": { <optional attributes as a JSON sub-schema> }
  }
}

Build a convention instance, add one or more CRS objects (each covering one or more dimension axes), then call as_list() to retrieve everything for inclusion as the "cs" attribute in the Zarr node metadata.

Super class

zarr::zarr_convention -> zarr_convention_cs

Active bindings

name

Optional descriptive name for the coordinate set.

cs_crs

Optional top-level CRS identifier, an instance of zarr_conv_proj.

crs

(read-only) The list of CRS objects accumulated so far.

Methods

Public methods

Inherited methods

zarr_convention_cs$new()

Create a new instance of a "cs" convention agent.

Usage
zarr_convention_cs$new()
Returns

A new instance of a "cs" convention agent.


zarr_convention_cs$add_crs()

Add a CRS object to this coordinate set. Each CRS covers one or more axes (dimensions). Multiple calls add further CRS objects to the array, which is necessary when the array spans domains described by separate OGC coordinate reference systems (e.g. a horizontal CRS plus a vertical CRS plus a temporal CRS).

Usage
zarr_convention_cs$add_crs(
  axes,
  type = "unknown",
  id = NULL,
  geolocation = NULL
)
Arguments
axes

A named list of axis definitions, keyed by the dimension name that appears in the Zarr array's dimension_names metadata. If the argument is NULL or an empty list, the call is a no-op.

type

Optional, character string. Type of CRS, one of "compound", "planar", "vertical", "temporal", "unknown" (default).

id

Optional. An instance of zarr_conv_proj providing the formal OGC description of the CRS.

geolocation

Optional list. Geolocation grid definition for curvilinear grids. This should only be included for CRS's that represent a planar coordinate system.

Returns

Self, invisibly.


zarr_convention_cs$as_list()

Retrieve the cs attributes as a list.

Usage
zarr_convention_cs$as_list()
Returns

A list with the updated attributes for this convention.


zarr_convention_cs$axis()

Build an axis definition.

Usage
zarr_convention_cs$axis(coordinates, abbreviation = NULL, direction = NULL)
Arguments
coordinates

A list of coordinate-set definitions, each produced by coordinates(). Must have at least one element.

abbreviation

Optional character string. Axis abbreviation, e.g. "X", "Y", "Z", or "T".

direction

Optional character string. Direction of increasing coordinate values taken from Table 48 of the OGC standard "Referencing by Coordinates" (e.g. "EAST", "NORTH", "UP", "FUTURE").

Returns

A named list representing one axis entry.


zarr_convention_cs$coordinates()

Build a coordinate-set definition for use in axis().

Usage
zarr_convention_cs$coordinates(
  values,
  name = NULL,
  unit = NULL,
  boundaries = NULL,
  parametric = NULL,
  time = NULL,
  attributes = NULL
)
Arguments
values

A values definition produced by one of values_regular(), values_explicit(), or values_external().

name

Optional, character string. Descriptive name for this set of coordinates.

unit

Optional, character string. Unit of measure (e.g. "degrees_east", "m", "1").

boundaries

Optional boundaries definition produced by boundaries_regular() or values_external().

parametric

Optional parametric definition produced by parametric().

time

Optional time definition produced by time().

attributes

Optional list with attributes for the coordinates.

Returns

A named list representing one coordinates entry.


zarr_convention_cs$values_regular()

Regularly-spaced coordinate values.

Usage
zarr_convention_cs$values_regular(start, increment)
Arguments
start

Numeric. The coordinate value at shape index 0.

increment

Numeric. The constant spacing between successive values. May be negative for decreasing coordinates (e.g. north-to-south latitudes); it cannot be 0.

Returns

A values list with a regular element.


zarr_convention_cs$values_explicit()

Explicitly listed coordinate values.

Usage
zarr_convention_cs$values_explicit(values)
Arguments
values

A vector of coordinate values. May be numeric, integer, or character.

Returns

A values list with an explicit element.


zarr_convention_cs$values_external()

Coordinate values stored in an external array

Usage
zarr_convention_cs$values_external(node, uri)
Arguments
node

Character string. Path to the 1-dimensional Zarr array containing the coordinate values, relative to the referring node.

uri

Optional character string. URI of an external store. Omit for arrays in the same local store.

Returns

A values list with an external element.


zarr_convention_cs$boundaries_regular()

Regularly-spaced cell-boundary values.

The two values give the offset below and above the coordinate value that define the extent of each cell, in the same unit as the coordinates. Both offsets are expressed relative to the coordinate value so below must be non-positive and above must be non-negative.

Usage
zarr_convention_cs$boundaries_regular(below, above)
Arguments
below, above

Numeric. Offset from the coordinate value to the lower and upper boundary, respectively.

Returns

A boundaries list with a regular element.


zarr_convention_cs$time()

Provides the time reference information needed to interpret numeric coordinate values on a temporal axis.

Usage
zarr_convention_cs$time(unit, epoch, calendar = NULL)
Arguments
unit

Character string. The time unit, e.g. "days", "hours", "seconds".

epoch

Character string. The reference date/time in ISO 8601 format, e.g. "1970-01-01".

calendar

Optional character string. The CF calendar name, e.g. "standard", "360_day". Defaults to "proleptic_gregorian" when omitted.

Returns

A time list.


zarr_convention_cs$parametric()

Records the CF formula name and the set of formula terms needed to derive physical coordinates from the stored parametric index coordinates. This object sits alongside values inside a coordinates() call; values provides the stored parametric coordinates (e.g. s_rho), while parametric provides the machinery to recover the physical coordinates (e.g. depth in metres).

Usage
zarr_convention_cs$parametric(formula, terms)
Arguments
formula

Character string. The CF standard_name of the parametric coordinate formula, e.g. "ocean_s_coordinate_g2".

terms

A named list of formula term values. Each element must be a values attribute object. Scalar or short constants should use explicit coordinate values; full-length arrays should use external Zarr arrays.

Returns

A parametric list.


geozarr documentation built on Sept. 16, 2026, 1:07 a.m.