Parameters
- grid: RasterGrid
- by: RasterGrid
Optionalopts: {
bins?: number | number[];
byNoData?: number;
method?: string;
noData?: number;
} = {}
Returns {
area: number;
class: string | number;
count: number;
max: number;
mean: number;
min: number;
range?: [number, number];
sum: number;
}[]
one row per non-empty
group, ordered by class/bin
Group a raster's pixels by another raster's values and reduce each group — the third kind of reduction, alongside
reduce()(collapse a selection axis) andzonalStats()(collapse space by geometry). This one collapses space by value: "mean depth per land-use class", "rainfall binned by elevation", a rating curve of one variable against another.It is deliberately NOT
select/reduce, and not an overload ofzonalStats: the grouping key comes from DATA rather than from the axis model or from geometry, so it earns its own verb rather than making an existing one mean two things.byis conformed togrid(resampled onto its cells) exactly ascombineGridsconforms its inputs — same LHS-conform rule, same resampler, so the two agree on what "aligned" means.Two grouping modes:
byis a class. For classification rasters (land use, soil type) where the values ARE the categories.bins: [0, 100, 500]uses those edges;bins: 5cutsby's finite range into five equal-width bands. For continuousby(elevation, discharge), where distinct values are useless.A pixel is skipped when EITHER raster is absent there (NaN or the respective noData), so the result only covers cells where both rasters actually have a value.