openforis / sepal

Geographical Data Processing in the Cloud
https://sepal.io/
MIT License
207 stars 46 forks source link

problem with class display vizualization when unzoom #151

Closed 12rambau closed 2 years ago

12rambau commented 2 years ago

Describe the bug

When a classification is displayed and the image is unzoomed a lot, the AOI becomes nearly fully black.

Capture d’écran 2021-12-06 à 15 02 35

To Reproduce

display the following asset in any recipe: users/bornToBeAlive/sepal_ui_test/imageViZExample and display the class preset vizaulization parmaters. You should see the following:

Capture d’écran 2021-12-06 à 15 02 27

Unzoom a lot and you'll see the first one.

Expected behavior

Based on the script that create the vizparams, the palette is paded as such:

    var paddedPalette = sequence(minValue, maxValue).map(function () {
      return '#000000'
    })
    values.forEach(function (value, i) {
      paddedPalette[value - minValue] = palette[i]
    })

meaning that every value between the values will be displayed as black. That could be a feature, forcing the user to zoom in. If that's not the case would it make sense to fill the "in-between" values of the palette with the previous one instead of black?

cdanielw commented 2 years ago

Which pyramiding policy was the asset exported with?

cdanielw commented 2 years ago

It looks like mean - you want to use mode or sample when exporting categorical bands.

You have this issue directly in ee: https://code.earthengine.google.com/2018f4ce94e2c8bfb1fa37a8421eefa6

cdanielw commented 2 years ago

You can do something like this to re-export it. That will give the class band a pyramiding policy of mode, while the rest of the bands are mean. You'll probably want to specify a bunch of other export properties too.

Export.image.toAsset({
  image: i, 
  pyramidingPolicy: {
    '.default': 'mean',
    'class': 'mode'
  }, 
})
12rambau commented 2 years ago

I aggree that pyramiding policy of this asset is mean and that it should be mode.

@cdanielw you are the one that provided me with this asset so can you confirm that any categorical asset created by SEPAL will use mode pyramiding policy ?

cdanielw commented 2 years ago

SEPAL export the class band in classifications in mode. I do have to verify that I specify pyramiding policy properly for categorical bands in index change and class change recipes though.

The asset I provided you with has the class band in mode: users/wiell/forum/visualization_example The one you used probably has the class band in mean: users/bornToBeAlive/sepal_ui_test/imageViZExample

Check out the script in my previous comment.

cdanielw commented 2 years ago

Lucky you raised this - it turns out I didn't specify the pyramiding policy for index changes and class changes.

12rambau commented 2 years ago

Lucky you raised this

perfect the issue wasn't useless after all, I'm happy to help!