Skip to content

Commit

Permalink
feat: ee layer masking
Browse files Browse the repository at this point in the history
  • Loading branch information
turban committed Nov 25, 2023
1 parent b47e5fe commit 7e29a4e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
13 changes: 7 additions & 6 deletions src/earthengine/ee_worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,9 @@ class EarthEngineWorker {
mosaic,
band,
bandReducer,
mask,
maskOperator,
methods,
style,
cloudScore,
} = this.options

Expand Down Expand Up @@ -174,9 +175,9 @@ class EarthEngineWorker {
}
}

// Mask out 0-values
if (mask) {
eeImage = eeImage.updateMask(eeImage.gt(0))
// Only keep pixels above min value
if (maskOperator && eeImage[maskOperator]) {
eeImage = eeImage.updateMask(eeImage[maskOperator](style?.min || 0))
}

// Run methods on image
Expand All @@ -191,7 +192,7 @@ class EarthEngineWorker {
getTileUrl() {
const { datasetId, format, data, filter, style } = this.options

return new Promise(resolve => {
return new Promise((resolve, reject) => {
switch (format) {
case FEATURE_COLLECTION:
let dataset = ee.FeatureCollection(datasetId)
Expand Down Expand Up @@ -231,7 +232,7 @@ class EarthEngineWorker {

break
default:
// TODO: Handle unknown format
reject(new Error('Unknown format'))
}
})
}
Expand Down
2 changes: 1 addition & 1 deletion src/utils/earthengine.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const workerOptions = [
'filter',
'format',
'legend',
'mask',
'maskOperator',
'methods',
'mosaic',
'periodReducer',
Expand Down

0 comments on commit 7e29a4e

Please sign in to comment.