2

I am processing Landsat 8 images to detect water quality parameters in R. I am using NDWI to masking the images. The raster layer I obtained from NDWI has negative values which I wanted to remove. Can anyone help me to do this?

2

Suppose you have a raster titled LandCover (used the name LC here). You can assign NA values to your RasterLayer for negative values.

 LC[LC < 0] <- NA

This will set a lower bound to the values.

  • 1
    Yes, and the memory safe equivalent would be calc(LC, fun = function(x){x[x < 0] <- NA; return(x)}) – Loïc Dutrieux Jul 4 '17 at 16:53

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.