set_convention: Set the GeoZarr convention with array details in the metadata...

View source: R/domain_geozarr.R

set_conventionR Documentation

Set the GeoZarr convention with array details in the metadata of the array

Description

This function will write the GeoZarr convention with all details into the metadata of a Zarr array.

Usage

set_convention(
  metadata,
  coord_sys,
  crs = NULL,
  external_group,
  registration = "pixel"
)

Arguments

metadata

A list with the basic metadata of the array.

coord_sys

The CoordinateSystem instance of the GeoZarr array.

crs

Optional, a list with 1 or more CRS definitions. Named list elements can be "compound", "spatial" (X-Y), "vertical" or "temporal". Those elements are a list themselves with one or more of the named elements "code", "wkt2" or "projjson" (for the attributes in the proj convention) with their value being the attribute to register. In the cs convention, a "compound" CRS will be associated with the coordinate system of the GeoZarr array, the other options will be associated with the specific CRSs of the coordinate system. In the spatial convention there can only be 1 CRS which must be of type "compound" or "spatial" and which is registered at the root of the "attributes" of the GeoZarr array.

external_group

Optional, the path to the group, relative to the location of the array, that stores any external arrays with coordinate values.

registration

Optional, the registration point of the array for use with the "spatial" convention. Defaults to "pixel".

Value

A list with the metadata updated with convention attributes.

Examples

ab <- zarr::array_builder$new()
ab$data_type <- "int32"
ab$shape <- c(1000L, 20L)

crd1 <- CoordinatesPacked$new("X_coordinates", "EAST", "m", c(0, 1000), 1000L)
ax1 <- CoordinateSystemAxis$new("Axis1", "X", crd1)
crd2 <- CoordinatesPacked$new("Y_coordinates", "NORTH", "m", c(0, 1000), 20L)
ax2 <- CoordinateSystemAxis$new("Axis2", "Y", crd2)

cs <- CoordinateSystem$new("CS", list(Axis1 = ax1, Axis2 = ax2))

crs <- list(spatial = list(code = "EPSG:4326"))

set_convention(ab$metadata(), cs, crs)

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