Global

Members

(constant) cacheAPI

Enhanced fetch with universal caching

Source:

(constant) GRIDDED_SOURCES

Configuration for gridded data sources Maps source name to DataSource class and method mapping Centralized in utils to keep data.js clean

Source:

(constant) modelRegistry

Fat Worker for Neural Network operations. Holds all model instances and performs all heavy computation.

Source:

Methods

(private) _dx()

Centralized band derivative

Source:

(async, private) _ensureLibraries()

Source:

(async, private) _ensureWorker()

Source:

(async, private) _openFromArrayBuffer()

Source:

(async) _openGDALSource()

Helper to initialize GDAL and open a source dataset. Reduces code duplication.

Source:

(private) _runWorker()

Source:

(private) _toGeorasterObject()

Source:

(async, private) _toGeoTIFF()

Source:

(async, private) addCustomLegend(param0)

Adds a custom legend to the map based on the map type and position specified.

Parameters:
Name Type Description
param0 Object

Object containing the map type and position for the legend.

Properties
Name Type Description
position string

The position for the legend (top, top left, left, bottom left, bottom, bottom right, right, top right).

Source:

(async) algebra(options) → {Promise.<Object>}

Performs arithmetic operations between two rasters.

Parameters:
Name Type Description
options Object
Properties
Name Type Description
args Object

Arguments.

Properties
Name Type Description
op string

Operation to perform: "add", "sub", "mul", or "div".

data Array.<Object>

Input data containing two objects with { buffer: ArrayBuffer }.

Source:
Returns:

Result containing the processed single-band GeoTIFF buffer.

Type
Promise.<Object>
Example
await hydro.analyze.geoprocessor.algebra({
  args: { op: 'sub' },
  data: [{ buffer: bufferA }, { buffer: bufferB }]
});

(async) aspect()

Calculates Aspect using GDAL.

Source:

(async) bandMath(options) → {Promise.<Object>}

Performs mathematical expressions on raster bands.

Parameters:
Name Type Description
options Object
Properties
Name Type Description
args Object

Arguments.

Properties
Name Type Description
expr string

Mathematical expression (e.g., "(nir-red)/(nir+red)").

bands Object.<string, number>

Mapping of variable names to band indices (e.g., { red: 0, nir: 3 }).

data Array.<Object>

Input data containing one object with { buffer: ArrayBuffer }.

Source:
Returns:

Result containing the processed single-band GeoTIFF buffer.

Type
Promise.<Object>
Example
await hydro.analyze.geoprocessor.bandMath({
  args: { expr: "(nir - red) / (nir + red)", bands: { red: 0, nir: 3 } },
  data: [{ buffer: multispectralBuffer }]
});

(async) clip(options) → {Promise.<Object>}

Clips a raster to a pixel-based window.

Parameters:
Name Type Description
options Object
Properties
Name Type Description
args Object

Arguments.

Properties
Name Type Description
window Array.<number>

Clipping window [startX, startY, endX, endY].

data Array.<Object>

Input data containing one object with { buffer: ArrayBuffer }.

Source:
Returns:

Result containing clipped GeoTIFF buffer.

Type
Promise.<Object>

(async) clipGeo(options) → {Promise.<ArrayBuffer>}

Clips a GeoTIFF to the specified bounding box using GDAL WASM (GDALTranslate).

Parameters:
Name Type Description
options Object
Properties
Name Type Description
args Object

Arguments.

Properties
Name Type Description
bounds Array.<number>

Bounding box [minX, minY, maxX, maxY].

data Array.<Object> | ArrayBuffer

Input data (ArrayBuffer of GeoTIFF).

Source:
Returns:

Clipped GeoTIFF buffer.

Type
Promise.<ArrayBuffer>

(private) convertAORCToNetCDF(data) → {Object}

Convert AORC data to NetCDF-compatible structure

Parameters:
Name Type Description
data Object

AORC data

Source:
Returns:

NetCDF-compatible structure

Type
Object

(async) convertGeoTIFFToGeoraster(tiff) → {Promise.<Object>}

Converts a GeoTIFF object (from geotiff.js) to the georaster format expected by layer functions

Parameters:
Name Type Description
tiff Object

GeoTIFF object

Source:
Returns:

Georaster-like object

Type
Promise.<Object>

(private) convertToArray()

Convert data to array format

Source:

(private) convertToCSV()

Convert data to CSV format based on source

Source:

(private) convertToNetCDF()

Convert data to NetCDF format based on source

Source:

(private) createGoogleMapsGeoRasterLayer(georaster, styleOptions) → {Object}

Creates a georaster layer for Google Maps using canvas overlay

Parameters:
Name Type Description
georaster Object

Georaster object with elevation data

styleOptions Object

Styling options for the layer

Source:
Returns:

Google Maps overlay object

Type
Object

(private) createLeafletCanvasGeoRasterLayer(georaster, options) → {Object}

Creates a canvas-based georaster layer for Leaflet (fallback)

Parameters:
Name Type Description
georaster Object

Georaster object with elevation data

options Object

Layer options

Source:
Returns:

Leaflet canvas layer

Type
Object

(async, private) createLeafletGeoRasterLayer(georaster, styleOptions) → {Object}

Creates a georaster layer for Leaflet

Parameters:
Name Type Description
georaster Object

Georaster object with elevation data

styleOptions Object

Styling options for the layer

Source:
Returns:

Leaflet layer object

Type
Object

createSegmentationModel()

Creates a simple Fully Convolutional Network (FCN) for segmentation. Preserves spatial dimensions using padding='same'.

Source:

(private) createSimpleGeoRasterOverlay(georaster, options) → {Object}

Creates a simple image overlay from georaster data

Parameters:
Name Type Description
georaster Object

Georaster object with elevation data

options Object

Layer options

Source:
Returns:

Leaflet image overlay

Type
Object

createStore()

Create a fetch store for the given URL

Source:

createTransformer()

Creates a simple Transformer model for time-series. Uses 1D convolution as a proxy for embedding + MultiHeadAttention (if available) or simplified attention. Since standard TF.js layers might be limited, we use a functional approach.

Source:

createZarrStore(url) → {Object}

Utility function for creating Zarr stores and arrays using zarrita

Parameters:
Name Type Description
url string

Base URL for the Zarr store

Source:
Returns:

Zarrita utilities

Type
Object

(async) decompressGzip(compressedData) → {Promise.<ArrayBuffer>}

Decompresses gzip data

Parameters:
Name Type Description
compressedData ArrayBuffer

Gzipped data

Source:
Returns:

Decompressed data

Type
Promise.<ArrayBuffer>

determinePRISMRegion(bbox) → {string}

Determine appropriate region based on bounding box

Parameters:
Name Type Description
bbox Array

Bounding box [west, south, east, north]

Source:
Returns:

Region code (us, ak, hi, pr)

Type
string

drawHtmlTable()

Renders a simple HTML table from 2D array data.

Source:

(async) execute(params, args, data) → {Promise.<Object>}

Executes a raster operation based on params.

Parameters:
Name Type Description
params Object

Action configuration.

Properties
Name Type Description
action string

The name of the function to execute (e.g. 'slope', 'hillshade').

args Object

Arguments specific to the action.

data Array.<Object>

Array of input data objects, each containing a buffer property (ArrayBuffer).

Source:
Returns:

Result object { ok, result, ... }.

Type
Promise.<Object>
Example
await hydro.analyze.geoprocessor.execute({
  params: { action: 'slope' },
  args: { cellSize: 30 },
  data: [{ buffer: arrayBuffer }]
});

(async) extractGRIB2Data(grib2Data, options) → {Promise.<Object>}

Extract GRIB2 data in HydroLang format

Parameters:
Name Type Description
grib2Data Object

Parsed GRIB2 data from parseGRIB2

options Object

Extraction options

Source:
Returns:

Extracted data in HydroLang format

Type
Promise.<Object>

(async) fillSinks(params) → {Promise.<ArrayBuffer>}

Fills sinks in a DEM (Priority-Flood).

Parameters:
Name Type Description
params Object

{ args: {}, data: ArrayBuffer }

Source:
Returns:

Filled DEM GeoTIFF.

Type
Promise.<ArrayBuffer>

flattenND(data) → {Array}

Recursively flattens an n-dimensional array.

Parameters:
Name Type Description
data Array

The nested array to flatten.

Source:
Returns:

A flat array.

Type
Array

formatPRISMTimePeriod(date, dataType) → {string}

Parse date to PRISM time period format

Parameters:
Name Type Description
date Date

Input date

dataType string

Type of data ('daily', 'monthly', 'annual', 'normals')

Source:
Returns:

Formatted time period string

Type
string

(private) generateNWMDateRange(startDate, endDate, frequency) → {Array.<Date>}

Generate NWM date range

Parameters:
Name Type Description
startDate Date

Start date

endDate Date

End date

frequency string

Frequency (hourly, daily)

Source:
Returns:

Array of dates

Type
Array.<Date>

generatePRISMFileURL(variable, region, resolution, timePeriod, format, stability) → {string}

Generate PRISM file URL based on parameters

Parameters:
Name Type Description
variable string

Variable name (ppt, tmin, etc.)

region string

Region code (us, ak, hi, pr)

resolution string

Resolution code (15s, 30s, 25m)

timePeriod string

Time period string

format string

Format type ('new' or 'legacy')

stability string

Stability level (legacy only)

Source:
Returns:

Complete download URL

Type
string

getArrayData()

Get full array data

Source:

getChunk()

Get array chunk

Source:

(async) getFile(params, args, data) → {Promise.<Object>}

Get a raw cached file for manual processing

Parameters:
Name Type Description
params Object

Parameters object

Properties
Name Type Description
source string

Data source

datatype string

Data type

args Object

Arguments object

Properties
Name Type Description
key string

Cache key to retrieve

data Object

Data object (unused)

Source:
Returns:

Raw file data and metadata

Type
Promise.<Object>

getInfo() → {Object}

Get GRIB2 library info

Source:
Returns:

Library info

Type
Object

(private) getLeafletColorForElevation(normalizedValue, colorScheme) → {Object}

Gets color for elevation value in Leaflet format

Parameters:
Name Type Description
normalizedValue number

Normalized elevation (0-1)

colorScheme string | Array

Color scheme name or array of hex colors

Source:
Returns:

RGB color object

Type
Object

(private) getMap() → {Object}

Returns the current map instance (Leaflet or Google Maps)

Source:
Returns:

Map instance

Type
Object

(private) getNWMTemporalInfo(datasetConfig) → {Object}

Get NWM temporal information

Parameters:
Name Type Description
datasetConfig Object

NWM dataset configuration

Source:
Returns:

Temporal information

Type
Object

getRecommendedPRISMResolution(region, dataType, format) → {string}

Get recommended resolution for region and data type

Parameters:
Name Type Description
region string

Region code

dataType string

Data type

format string

Format type ('new' or 'legacy')

Source:
Returns:

Recommended resolution code

Type
string

getRegion()

Get array region

Source:

goldfeldQuandtTest(params, args, data) → {Object}

Performs Goldfeld-Quandt test for heteroscedasticity.

Parameters:
Name Type Description
params Object

Not used by this function.

args Object

Not used by this function.

data Object

Contains: residuals (Array of residuals from a regression model) and independentVar (Array of values of the independent variable).

Author:
  • riya-patil
Source:
Throws:

If the input arrays have different lengths.

Type
Error
Returns:

Object containing test statistic and p-value.

Type
Object
Example
const residuals = [1.2, 2.3, 0.8, 1.9, 1.5, 2.6];
const independentVar = [3, 4, 5, 6, 7, 8];
const result = stats.goldfeldQuandtTest({ data: { residuals, independentVar } });
console.log(result);

gridToTensor(params) → {tf.Tensor}

Converts 2D grid data (e.g., from GRIB2/Zarr decoders) to a Tensor. Can handle adding a channel dimension if needed (e.g., for CNNs).

Parameters:
Name Type Description
params Object

{ data, rows, cols }

Source:
Returns:

Tensor of shape [1, rows, cols, 1]

Type
tf.Tensor

(async) hillshade(options) → {Promise.<ArrayBuffer>}

Calculates Hillshade using GDAL.

Parameters:
Name Type Description
options Object
Properties
Name Type Description
args Object

Arguments.

Properties
Name Type Attributes Default Description
zFactor number <optional>
1

Vertical exaggeration.

scale number <optional>
1

Ratio of vertical units to horizontal.

azimuth number <optional>
315

Azimuth of the light (degrees).

altitude number <optional>
45

Altitude of the light (degrees).

data Array.<Object>

Input data containing a DEM { buffer: ArrayBuffer }.

Source:
Returns:

Hillshade raster buffer.

Type
Promise.<ArrayBuffer>

imgToTensor(params) → {tf.Tensor4D}

Converts an image (HTMLImageElement, Canvas, or pixel array) to a 4D Tensor. Useful for CNN inputs.

Parameters:
Name Type Description
params Object

{ image, width, height, channels }

Source:
Returns:

Tensor of shape [1, height, width, channels]

Type
tf.Tensor4D

(async) info(options) → {Promise.<Object>}

Extracts metadata from a GeoTIFF buffer.

Parameters:
Name Type Description
options Object
Properties
Name Type Description
data Array.<Object>

Input data containing one object with { buffer: ArrayBuffer }.

Source:
Returns:

Metadata object including width, height, bbox, origin, resolution, and native directory.

Type
Promise.<Object>
Example
await hydro.analyze.geoprocessor.info({
  data: [{ buffer: arrayBuffer }]
});

isLoaded() → {boolean}

Check if GRIB2 library is loaded

Source:
Returns:

True if loaded

Type
boolean

(async) load(options) → {Promise.<Object>}

Load function for GRIB2 library integration

Parameters:
Name Type Description
options Object

Load options

Source:
Returns:

Loaded GRIB2 library interface

Type
Promise.<Object>

(async, private) loadGeoRasterLayerPlugin() → {Promise.<void>}

Attempts to load the GeoRasterLayer plugin for Leaflet

Source:
Returns:
Type
Promise.<void>

(async) loadGeoTIFFFromBuffer(arrayBuffer) → {Promise.<Object>}

Loads GeoTIFF from array buffer directly

Parameters:
Name Type Description
arrayBuffer ArrayBuffer

Raw TIFF data

Source:
Returns:

Parsed TIFF data

Type
Promise.<Object>

(async) mapPixels(options) → {Promise.<Float32Array>}

Map a function over every pixel in a raster.

Parameters:
Name Type Description
options Object
Properties
Name Type Description
args Object

Arguments.

Properties
Name Type Description
func function | string

Function(val, x, y) or string body.

data Array.<Object>

Input data { buffer: ArrayBuffer }.

Source:
Returns:

Raw raster data (Float32Array).

Type
Promise.<Float32Array>

(async) mask(options) → {Promise.<Object>}

Creates a binary mask based on min/max threshold values.

Parameters:
Name Type Description
options Object
Properties
Name Type Description
args Object

Arguments.

Properties
Name Type Attributes Default Description
min number <optional>
-Infinity

Minimum value (inclusive).

max number <optional>
Infinity

Maximum value (inclusive).

data Array.<Object>

Input data containing one object with { buffer: ArrayBuffer }.

Source:
Returns:

Result containing binary mask (0 or 1).

Type
Promise.<Object>
Example
await hydro.analyze.geoprocessor.mask({
  args: { min: 0, max: 1000 },
  data: [{ buffer: demBuffer }]
});

openArray()

Open a Zarr array from the store

Source:

(async) parseGRIB2(buffer) → {Promise.<Object>}

Parse GRIB2 file buffer using standalone parser

Parameters:
Name Type Description
buffer ArrayBuffer

GRIB2 file buffer

Source:
Returns:

Parsed GRIB2 data

Type
Promise.<Object>

(async) pca(options) → {Promise.<Object>}

Performs Principal Component Analysis (PCA) on multiband rasters.

Parameters:
Name Type Description
options Object
Properties
Name Type Description
args Object

Arguments.

Properties
Name Type Attributes Description
components number <optional>

Number of PCA components to keep. Defaults to all bands.

data Array.<Object>

Input data containing a multiband raster { buffer: ArrayBuffer }.

Source:
Returns:

Result containing multi-band GeoTIFF with principal components.

Type
Promise.<Object>
Example
await hydro.analyze.geoprocessor.pca({
  args: { components: 3 },
  data: [{ buffer: multibandBuffer }]
});

(private) preprocess(params, data) → {Array}

Preprocesses 1D data into LSTM-ready 3D format.

Parameters:
Name Type Description
params Object

Contains: inputWindow (timeSteps), outputWindow (predictions).

data Array

1D array of values.

Source:
Returns:

[X, y] where X is 3D array and y is 2D array.

Type
Array

(private) processAORCBulkExtraction(args, datasetConfig) → {Promise.<Object>}

Process AORC bulk extraction request

Parameters:
Name Type Description
args Object

Request arguments

datasetConfig Object

AORC dataset configuration

Source:
Returns:

Bulk extraction results

Type
Promise.<Object>

processGriddedSource(source, dataType, args, datasources) → {Promise}

Generic processor for all gridded data sources Replaces 8 individual processXXXData functions with a single unified handler Centralized in utils to keep data.js clean

Parameters:
Name Type Description
source string

Source name (e.g., 'aorc', 'mrms', 'hrrr')

dataType string

Data type (e.g., 'point-data', 'grid-data')

args Object

Arguments for data extraction

datasources Object

Datasources configuration object

Source:
Returns:

Result from data source

Type
Promise

(async) recenter(param0)

Parameters:
Name Type Description
param0 *
Source:

(async) reproject(options) → {Promise.<Object>}

Reprojects a raster to a different Coordinate Reference System (CRS).

Parameters:
Name Type Description
options Object
Properties
Name Type Description
args Object

Arguments.

Properties
Name Type Attributes Default Description
dstCRS string

Destination CRS definition (WKT or Proj4 string).

srcCRS string <optional>

Source CRS definition. If not provided, attempts to read from GeoTIFF keys.

width number <optional>

Output width.

height number <optional>

Output height.

method string <optional>
'nearest'

Resampling method ('nearest', 'bilinear').

data Array.<Object>

Input data containing one object with { buffer: ArrayBuffer }.

Source:
Returns:

Result containing reprojected GeoTIFF buffer.

Type
Promise.<Object>
Example
await hydro.analyze.geoprocessor.reproject({
  args: { dstCRS: 'EPSG:3857' },
  data: [{ buffer: bufferIn4326 }]
});

(async) saveFile(params, args, data) → {Promise.<boolean>}

Save processed data with a user-defined key

Parameters:
Name Type Description
params Object

Parameters object

Properties
Name Type Description
source string

Data source

datatype string

Data type

args Object

Arguments object

Properties
Name Type Description
key string

User-defined key for the dataset

name string

Optional human-readable name

data Object

Data object to save

Source:
Returns:

Success status

Type
Promise.<boolean>

seriesToTensor(params) → {Object}

Prepares time-series data for LSTM (Samples, TimeSteps, Features).

Parameters:
Name Type Description
params Object

{ data, windowSize }

Source:
Returns:

{ inputs, outputs } tensors

Type
Object

(async) slope()

Calculates Slope using GDAL.

Source:

sourceType(args, dataType) → {string}

Generates the URL for CHIRPS data based on user arguments.

Parameters:
Name Type Description
args Object

Arguments for the request

dataType string

Type of data requested (mapped to dataset key)

Source:
Returns:

Fully constructed URL

Type
string

(async) streamExtract(options) → {Promise.<Object>}

Extracts stream networks based on flow accumulation threshold.

Parameters:
Name Type Description
options Object
Properties
Name Type Description
args Object

Arguments.

Properties
Name Type Attributes Default Description
threshold number <optional>
1000

Accumulation threshold to define a stream.

data Array.<Object>

Input data containing a DEM { buffer: ArrayBuffer }.

Source:
Returns:

Result containing binary stream mask.

Type
Promise.<Object>
Example
await hydro.analyze.geoprocessor.streamExtract({
  args: { threshold: 500 },
  data: [{ buffer: demBuffer }]
});

(async) tile(options) → {Promise.<Object>}

Splits a raster into smaller tiles.

Parameters:
Name Type Description
options Object
Properties
Name Type Description
args Object

Arguments.

Properties
Name Type Attributes Default Description
tileSize number <optional>
256

Width/Height of tiles in pixels.

data Array.<Object>

Input data containing one object with { buffer: ArrayBuffer }.

Source:
Returns:

Result containing array of tile objects.

Type
Promise.<Object>
Example
await hydro.analyze.geoprocessor.tile({
  args: { tileSize: 512 },
  data: [{ buffer: largeRasterBuffer }]
});

transformVariable()

Transform a single gridded data variable with comprehensive manipulations

Source:

validatePRISMVariable(variable, dataType) → {boolean}

Validate PRISM variable availability for data type

Parameters:
Name Type Description
variable string

Variable name

dataType string

Data type ('normals', 'monthly', 'daily')

Source:
Returns:

True if variable is available for data type

Type
boolean

(async) vectorize(options) → {Promise.<Object>}

Vectorizes a binary raster mask into GeoJSON Polygons.

Parameters:
Name Type Description
options Object
Properties
Name Type Attributes Default Description
args Object <optional>
{}

Arguments.

data Array.<Object>

Input data containing a DEM/Mask { buffer: ArrayBuffer }.

Source:
Returns:

Resulting GeoJSON FeatureCollection.

Type
Promise.<Object>
Example
const geojson = await hydro.analyze.geoprocessor.vectorize({
  data: [{ buffer: maskBuffer }]
});

whitesTest(params, args, data) → {Object}

Performs White's test for heteroscedasticity.

Parameters:
Name Type Description
params Object

Not used by this function.

args Object

Not used by this function.

data Object

Contains: errors (array of residuals) and regressors (array of regressor vars).

Author:
  • riya-patil
Source:
Throws:

If the input arrays have different lengths.

Type
Error
Returns:

Object containing test statistic and p-value.

Type
Object
Example
const params = {
  errors: [1, 2, 3, 4, 5],
  regressors: [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1]]
};
hydro.analyze.stats.whitesTest({ data: params });