@seasketch/geoprocessing
Version:
Geoprocessing and reporting framework for SeaSketch 2.0
46 lines (45 loc) • 2.27 kB
TypeScript
import { Polygon, Sketch, SketchCollection, Feature, MultiPolygon, FeatureCollection, MetricDimension } from "../../types/index.js";
import { Georaster } from "geoblaze";
import { StatsObject, CalcStatsOptions } from "../../types/geoblaze.js";
export declare const defaultStatValues: {
area: number;
histogram: {};
count: number;
invalid: number;
max: null;
mean: null;
median: null;
min: null;
mode: null;
product: null;
range: null;
sum: number;
std: null;
valid: number;
variance: null;
};
/**
* options accepted by rasterStats
* @extends CalcStatsOptions - options passed on to calcStats and calc-stats package. See See https://github.com/DanielJDufour/calc-stats/tree/main?tab=readme-ov-file#advanced-usage
*/
export interface RasterStatsOptions extends CalcStatsOptions {
/** single sketch or sketch collection filter to overlap with raster when calculating metrics. */
feature?: Feature<Polygon | MultiPolygon> | FeatureCollection<Polygon | MultiPolygon> | Sketch<Polygon | MultiPolygon> | SketchCollection<Polygon | MultiPolygon>;
/** undocumented filter function (how different from filter option above?), for example a => a > 0 will filter out pixels greater than zero such that 'valid' is number of valid pixels greater than 0 */
filterFn?: (cellValue: number) => boolean;
/** Optional number of bands in the raster, defaults to 1, used to initialize zero values */
numBands?: number;
/** If categorical raster, set to true */
categorical?: boolean;
/** If categorical raster, metric property name that categories are organized. Defaults to classId */
categoryMetricProperty?: MetricDimension;
/** If categorical raster, array of values to create metrics for. Any values not provided won't be counted */
categoryMetricValues?: string[];
}
/**
* Calculates over 10 different raster statistics, optionally constrains to raster cells overlapping with feature (zonal statistics).
* Defaults to calculating only sum stat
* If no raster cells with value found, returns 0 or null value for each stat as appropriate.
* @throws any errors
*/
export declare const rasterStats: (raster: Georaster, options?: RasterStatsOptions) => Promise<StatsObject[]>;