0

I need to add several layers in Google Earth Engine. Everything works fine except some layers have masks and the resulting image does include masked regions. I need masked regions to contain a value of 1.

var threat2 = presz.add(slopeii.add(zonesZ.add(changeZ.add(lossZ))));
supercontra
  • 165
  • 1
  • 9
  • It would be helpful if you could share your full code / workflow. – Val Oct 16 '18 at 07:26
  • Sorry, but your link doesn't help very much. The variables you use in your post above don't even exist in the code ... – Val Oct 17 '18 at 08:10
  • I'm sorry. This is the correct link: https://code.earthengine.google.com/27c7f12487911f428ed33ed3cac0ce8b – supercontra Oct 17 '18 at 11:54
  • I have found my error but still can't fix it. One layer, changeZ, contains NAN values. I know how to replace it in R but not in GEE. – supercontra Oct 17 '18 at 12:14
  • I've noticed the scaling didn't work as expected, as the values aren't clamped. Can you try `var changeZ = change.unitScale(-50,50).clamp(0, 1).multiply(4).add(1)` instead? Besides that, it's difficult to help, such a big script with a lot of mapping is confusing. If the problem still persists, can you remove unnecessary parts and explain a bit more detailed where the problem occurs? – Val Oct 17 '18 at 12:26

1 Answers1

1

If you want to unmask all masked pixels and assign a value of 1 for each of them, just use the unmask method of ee.Image.

Assume my_image is the image with mask.

unmasked_image = my_image.unmask(1);
Kevin
  • 338
  • 1
  • 3
  • 9