0

I want to display my water occurance layer whose value ranges from 0% to 100% as the sample in GEE, but I did not find the corresponding visualization parameters in its Data User Guide.

sample

Does anyone have ideas?

1 Answer 1

4

The script which produces this image can be found in the Code Editor's Scripts tab under Examples/Datasets/JRC_GSW1_0_GlobalSurfaceWater, and its text is:

var dataset = ee.Image('JRC/GSW1_0/GlobalSurfaceWater');
var occurrence = dataset.select('occurrence');
var occurrenceVis = {
  min: 0.0,
  max: 100.0,
  palette: ['ffffff', 'ffbbbb', '0000ff'],
};
Map.setCenter(59.414, 45.182, 6);
Map.addLayer(occurrence, occurrenceVis, 'Occurrence');

The appearance is not partially transparent red, but a palette containing reddish white (ffbbbb) and white.

3
  • Is it possible to set opacity attribute for each color in palette respectively, that is, the reddish white is 1% opacity while the white and red is completely opaque? Anyway, your answer is acceptable, since the layer style you provide looks like what I want. Thanks, Kevin. Commented Feb 24, 2020 at 1:15
  • @NickCarraway Opacity is determined not by the palette but by the mask of the image. The tidiest way I can think of to do that in the same format is to use Image.visualize() to apply a palette to the image and then use one band (red, green, or blue) of the produced visualization-image as a new mask for the actually displayed image.
    – Kevin Reid
    Commented Feb 24, 2020 at 3:45
  • 1
    @NickCarraway regarding variation in opacity, you might find some helpful code in the ImageCollection visualization guide as well. Commented Feb 24, 2020 at 16:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.