Skip to content

Commit

Permalink
Fix exception when attempting to calculate ckmeans for more buckets t…
Browse files Browse the repository at this point in the history
…han there are unique values
  • Loading branch information
underbluewaters committed Oct 11, 2024
1 parent 160982a commit 4148b3b
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions packages/spatial-uploads-handler/src/rasterInfoForBands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,19 +249,21 @@ export async function rasterInfoForBands(
n,
quantileBuckets(sampledPixelValues, n, b.minimum, b.maximum, true, true)
);
addBuckets(
b.stats.naturalBreaks,
n,
naturalBreaksBuckets(
sampledPixelValues,
if (sampledPixelValues.length > n) {
addBuckets(
b.stats.naturalBreaks,
n,
b.stats.histogram.length,
b.minimum,
b.maximum,
10000,
true
)
);
naturalBreaksBuckets(
sampledPixelValues,
n,
b.stats.histogram.length,
b.minimum,
b.maximum,
10000,
true
)
);
}
// Seems to be a quirk in the library where it returns -9999 for stdev when it can't be calculated
if (b.stats.stdev !== -9999) {
addBuckets(
Expand Down

0 comments on commit 4148b3b

Please sign in to comment.