new geoprocessor()
Geoprocessor module for raster data analysis using GeoTIFF.
Methods
(async, static) flowAccumulation(options) → {Promise.<ArrayBuffer>}
Calculate flow accumulation from flow direction raster Counts upstream cells flowing into each cell Higher values indicate stream channels and drainage paths
Parameters:
| Name | Type | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | Function options Properties
|
Returns:
Flow accumulation raster as GeoTIFF
- Type
- Promise.<ArrayBuffer>
Examples
// Calculate flow accumulation
const flowDir = await hydro.analyze.geoprocessor.flowDirection({ data: demBuffer });
const flowAcc = await hydro.analyze.geoprocessor.flowAccumulation({ data: flowDir });
// High values (>1000) indicate likely stream channels
// Extract stream network from flow accumulation
const flowAcc = await hydro.analyze.geoprocessor.flowAccumulation({ data: flowDir });
const streams = await hydro.analyze.geoprocessor.streamExtract({
args: { threshold: 500 }, // Cells with >500 upstream cells
data: flowAcc
});
(async, static) flowDirection(options) → {Promise.<ArrayBuffer>}
Calculate flow direction from DEM using D8 algorithm Determines direction of steepest descent for each cell Essential for watershed delineation and stream network extraction
Parameters:
| Name | Type | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | Function options Properties
|
Returns:
Flow direction raster (values 1-128) as GeoTIFF
- Type
- Promise.<ArrayBuffer>
Examples
// Calculate flow direction from DEM
const dem = await hydro.data.retrieve({
params: { source: '3dep', datatype: 'DEM' },
args: { bbox: [-105.5, 40.0, -105.0, 40.5] }
});
const flowDir = await hydro.analyze.geoprocessor.flowDirection({ data: dem });
// Direction values: 1=E, 2=SE, 4=S, 8=SW, 16=W, 32=NW, 64=N, 128=NE
// Complete watershed workflow
const flowDir = await hydro.analyze.geoprocessor.flowDirection({ data: dem });
const flowAcc = await hydro.analyze.geoprocessor.flowAccumulation({ data: flowDir });
const streams = await hydro.analyze.geoprocessor.streamExtract({
args: { threshold: 1000 },
data: flowAcc
});
(async, static) roughness(options) → {Promise.<ArrayBuffer>}
Calculate terrain roughness using GDAL Measures difference between max and min elevation in neighborhood Indicates vertical terrain variation
Parameters:
| Name | Type | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | Function options Properties
|
Returns:
Roughness raster as GeoTIFF
- Type
- Promise.<ArrayBuffer>
Example
// Calculate surface roughness
const roughness = await hydro.analyze.geoprocessor.roughness({ data: demBuffer });
// High values = very rough surface (cliffs, rock outcrops)
// Low values = smooth surface (plains, gentle slopes)
(async, static) tpi(options) → {Promise.<ArrayBuffer>}
Calculate Topographic Position Index (TPI) using GDAL Compares elevation of each cell to mean of surrounding cells Positive=ridges/hilltops, Negative=valleys, Zero=flat/mid-slope
Parameters:
| Name | Type | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | Function options Properties
|
Returns:
TPI raster as GeoTIFF
- Type
- Promise.<ArrayBuffer>
Example
// Identify ridges and valleys
const tpi = await hydro.analyze.geoprocessor.tpi({ data: demBuffer });
// Positive values = ridges, negative = valleys
// Use for landform classification
(async, static) tri(options) → {Promise.<ArrayBuffer>}
Calculate Terrain Ruggedness Index (TRI) using GDAL Measures terrain heterogeneity - higher values = more rugged terrain Useful for habitat modeling, geomorphology, and terrain classification
Parameters:
| Name | Type | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | Function options Properties
|
Returns:
TRI raster as GeoTIFF
- Type
- Promise.<ArrayBuffer>
Example
// Calculate terrain ruggedness
const dem = await hydro.data.retrieve({
params: { source: '3dep', datatype: 'DEM' },
args: { bbox: [-105.5, 40.0, -105.0, 40.5] }
});
const tri = await hydro.analyze.geoprocessor.tri({ data: dem });
// Higher values indicate more rugged, complex terrain
(async, static) watershed(options) → {Promise.<ArrayBuffer>}
Delineate watershed boundary from pour point Identifies all cells that drain to specified outlet location Critical for catchment analysis and hydrologic modeling
Parameters:
| Name | Type | Description | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | Function options Properties
|
Returns:
Watershed boundary raster as GeoTIFF
- Type
- Promise.<ArrayBuffer>
Examples
// Delineate watershed for stream gauge location
const flowDir = await hydro.analyze.geoprocessor.flowDirection({ data: dem });
const watershed = await hydro.analyze.geoprocessor.watershed({
args: { pourPoint: [-105.25, 40.25] }, // Gauge location
data: flowDir
});
// Complete watershed analysis workflow
const dem = await hydro.data.retrieve({
params: { source: '3dep', datatype: 'DEM' },
args: { bbox: [-105.5, 40.0, -105.0, 40.5] }
});
const flowDir = await hydro.analyze.geoprocessor.flowDirection({ data: dem });
const watershed = await hydro.analyze.geoprocessor.watershed({
args: { pourPoint: [-105.25, 40.25] },
data: flowDir
});
// Visualize watershed boundary
const map = hydro.map.renderMap({ params: { lat: 40.25, lon: -105.25, zoom: 11 } });
hydro.map.Layers({ params: { data: watershed, type: 'georaster' } });