I am computing the NDWI of an area , and I used the code below to generate a result of pixel value 1 and 0 only. Pixel value 1 will be displayed in blue means the pixel's NDWI value once had exceeded 0.3 and pixel value 0 will be displayed in white meaning the pixel's NDWI value has never reach 0.3 or more

var gte3 = ndwi.map(function(image){ return image.gte(0.3); }); var ndwigt3 = gte3.max(); var ndwigte3Viz = {min: 0, max: 1, palette: ['white', 'blue']}; Map.addLayer(ndwiget3, ndwigte3Viz , 'ndwigte3', false);

I could see the white and blue pixels when i open the layer in code editor, but once i output it with the following code, it turns out to be a total black image

Export.image.toDrive({ image: ndwigte3, description: 'ndwigte3', region: Border, scale: 30, maxPixels:1e13, skipEmptyTiles: false });


The issue is that the visualisation parameters that you specify for the Map.addLayer() are only used for that function. They haven't in any way modified the original raster. When you export it, the value goes from 0-1 however, the data is an 8Bit unsigned integer. Which means if you open it in a generic image viewer, it will give grayscale values (from 0-255) to all your pixels of black. (all are practically 0)

If you open the tiff in QGIS, it will adapt the vizalization so that the min is black and the max is white by default. (0-1).

If you modify your code as follows:

// multiply image by 255 making all 1 values to 255
var ndwigtVIZ = ndwigt3.multiply(255)

// Export Image
  image: ndwigtVIZ,
  description: 'ndwigtVIZ',
  region: Border,
  scale: 30,
  skipEmptyTiles: false

You should be able to see it fine. (black for non water and white for water)

I am sorry I am unable to help on the colorisation, as I don't know how to do that bit.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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