@seasketch/geoprocessing
Version:
Geoprocessing and reporting framework for SeaSketch 2.0
90 lines (89 loc) • 4.6 kB
TypeScript
import { Sketch, Feature, Polygon, SketchCollection, Metric, Georaster } from "../types/index.js";
type OverlapGroupOperation = (metricId: string, features: Feature<Polygon>[] | Georaster, sc: SketchCollection<Polygon>) => Promise<number>;
/**
* Generate overlap group metrics using rasterMetrics operation
*/
export declare function overlapRasterGroupMetrics(options: {
/** Caller-provided metric ID */
metricId: string;
/** Group identifiers - will generate group metric for each, even if result in zero value, so pre-filter if want to limit */
groupIds: string[];
/** Sketch - single or collection */
sketch: Sketch<Polygon> | SketchCollection<Polygon>;
/** Function that given sketch metric and group name, returns true if sketch is in the group, otherwise false */
metricToGroup: (sketchMetric: Metric) => string;
/** The metrics to group */
metrics: Metric[];
/** Raster to overlap, keyed by class ID */
featuresByClass: Record<string, Georaster>;
/** only generate metrics for groups that sketches match to, rather than all */
onlyPresentGroups?: boolean;
}): Promise<Metric[]>;
/**
* Generate overlap group metrics using overlapFeatures operation
*/
export declare function overlapFeaturesGroupMetrics(options: {
/** Caller-provided metric ID */
metricId: string;
/** Group identifiers - will generate group metric for each, even if result in zero value, so pre-filter if want to limit */
groupIds: string[];
/** Sketch - single or collection */
sketch: Sketch<Polygon> | SketchCollection<Polygon>;
/** Function that given sketch metric and group name, returns true if sketch is in the group, otherwise false */
metricToGroup: (sketchMetric: Metric) => string;
/** The metrics to group */
metrics: Metric[];
/** features to overlap, keyed by class ID, use empty array if overlapArea operation */
featuresByClass: Record<string, Feature<Polygon>[]>;
/** only generate metrics for groups that sketches match to, rather than all */
onlyPresentGroups?: boolean;
}): Promise<Metric[]>;
/**
* Generate overlap group metrics using overlapArea operation
* @deprecated - use overlapFeaturesGroupMetrics instead
*/
export declare function overlapAreaGroupMetrics(options: {
/** Caller-provided metric ID */
metricId: string;
/** Group identifiers */
groupIds: string[];
/** Sketch - single or collection */
sketch: Sketch<Polygon> | SketchCollection<Polygon>;
/** Function that given sketch metric and group name, returns true if sketch is in the group, otherwise false */
metricToGroup: (sketchMetric: Metric) => string;
/** The metrics to group */
metrics: Metric[];
classId: string;
/** area of outer boundary (typically EEZ or planning area) */
outerArea: number;
/** only generate metrics for groups that sketches match to, rather than all */
onlyPresentGroups?: boolean;
}): Promise<Metric[]>;
/**
* Given overlap metrics stratified by class and sketch, returns new metrics also stratified by group
* Assumes a sketch is member of only one group, determined by caller-provided metricToGroup
* For each group+class, calculates area of overlap between sketches in group and featuresByClass (with overlap between group sketches removed first)
* Types of metrics returned:
* sketch metrics: copy of caller-provided sketch metrics with addition of group ID
* overall metric for each group+class: takes sketches in group, subtracts overlap between them and overlap with higher group sketches, and runs operation
* If a group has no sketches in it, then no group metrics will be included for that group, and group+class metric will be 0
*/
export declare function overlapGroupMetrics(options: {
/** Caller-provided metric ID */
metricId: string;
/** Group identifiers */
groupIds: string[];
/** Sketch - single or collection */
sketch: Sketch<Polygon> | SketchCollection<Polygon>;
/** Function that given sketch metric returns the group ID */
metricToGroup: (sketchMetric: Metric) => string;
/** The metrics to group */
metrics: Metric[];
/** features to overlap, keyed by class ID, use empty array if overlapArea operation */
featuresByClass: Record<string, Feature<Polygon>[]> | Record<string, Georaster>;
/** overlap operation, defaults to overlapFeatures */
operation: OverlapGroupOperation;
/** only generate metrics for groups that sketches match to, rather than all groupIds */
onlyPresentGroups?: boolean;
}): Promise<Metric[]>;
export {};