Skip to main content

calculateSliceArgs()

function calculateSliceArgs(
shape,
dataSlice,
dimIndices,
selectors): SliceArgs;

Constructs Zarr slice arguments for extracting a subregion of a multidimensional array.

This function:

  • Converts geographic / elevation slice ranges into Zarr slice objects.
  • Converts value-based selectors (e.g. {type: "value", selected: 2020}) into nearest index selectors.
  • Optionally loads dimension coordinate arrays for the selected slice.
  • Produces a new selector map describing index-based selections.

Parameters

ParameterTypeDescription
shapenumber[]Full array shape.
dataSliceDataSlicePropsPixel-space slice ranges { startX, endX, startY, endY, startElevation?, endElevation? } (see DataSliceProps).
dimIndicesDimIndicesPropsMapping of dimension names → indices as returned by identifyDimensionIndices (see DimIndicesProps).
selectorsZarrSelectorsUser-provided selection map (lat/lon/elevation/time/etc.). See ZarrSelectors.

Returns

SliceArgs

An object containing:

  • sliceArgs: Array of slice objects/indexes matching the array's dimensions. See SliceArgs.
  • dimensionValues: Possibly updated coordinate arrays.
  • selectors: Updated index-based selectors. See ZarrSelectors.