Members
(constant) cacheAPI
Enhanced fetch with universal caching
(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.
Methods
(private) _dx()
Centralized band derivative
(async, private) _ensureLibraries()
(async, private) _ensureWorker()
(async, private) _openFromArrayBuffer()
(async) _openGDALSource()
Helper to initialize GDAL and open a source dataset. Reduces code duplication.
(private) _runWorker()
(private) _toGeorasterObject()
(async, private) _toGeoTIFF()
(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
|
- Source:
(async) algebra(options) → {Promise.<Object>}
Performs arithmetic operations between two rasters.
Parameters:
| Name | Type | Description | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
Properties
|
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.
(async) bandMath(options) → {Promise.<Object>}
Performs mathematical expressions on raster bands.
Parameters:
| Name | Type | Description | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
Properties
|
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
|
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
|
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
(private) convertToCSV()
Convert data to CSV format based on source
(private) convertToNetCDF()
Convert data to NetCDF format based on 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'.
(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
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.
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 |
Returns:
Zarrita utilities
- Type
- Object
(async) decompressGzip(compressedData) → {Promise.<ArrayBuffer>}
Decompresses gzip data
Parameters:
| Name | Type | Description |
|---|---|---|
compressedData |
ArrayBuffer | Gzipped data |
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] |
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
|
||||||
args |
Object | Arguments specific to the action. |
||||||
data |
Array.<Object> | Array of input data objects, each containing a |
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 |
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 } |
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. |
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') |
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) |
Returns:
Complete download URL
- Type
- string
(async) getFile(params, args, data) → {Promise.<Object>}
Get a raw cached file for manual processing
Parameters:
| Name | Type | Description | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
params |
Object | Parameters object Properties
|
|||||||||
args |
Object | Arguments object Properties
|
|||||||||
data |
Object | Data object (unused) |
- Source:
Returns:
Raw file data and metadata
- Type
- Promise.<Object>
getInfo() → {Object}
Get GRIB2 library info
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') |
Returns:
Recommended resolution code
- Type
- string
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). |
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 } |
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
|
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 } |
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
|
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
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 |
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 |
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
|
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
|
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 }]
});
(async) parseGRIB2(buffer) → {Promise.<Object>}
Parse GRIB2 file buffer using standalone parser
Parameters:
| Name | Type | Description |
|---|---|---|
buffer |
ArrayBuffer | GRIB2 file buffer |
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
|
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
|
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
|
|||||||||
args |
Object | Arguments object Properties
|
|||||||||
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 } |
Returns:
{ inputs, outputs } tensors
- Type
- Object
(async) slope()
Calculates Slope using GDAL.
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) |
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
|
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
|
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') |
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
|
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). |
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 });