rspatial / raster

R raster package https://rspatial.github.io/raster/reference/raster-package.html
GNU General Public License v3.0
161 stars 52 forks source link

'Plot' function in 'raster' package shows values above 'zlim' max as blank #251

Closed shirleyxyliu closed 2 years ago

shirleyxyliu commented 2 years ago

Hi just writing to see if anyone could kindly help checking the 'plot' function in 'raster' package. When I specified 'zlim' in 'plot' function, the plot show any value exceeding 'zlim' upper limit (50 in my case) as blank cells. Thanks in advance!

plot(r.emis.4km, zlim=c(0,50))

Screen Shot 2022-02-10 at 6 10 04 PM
rhijmans commented 2 years ago

That is by design.

Instead of

f <- system.file("ex/elev.tif", package="terra") 
r <- raster(f)
plot(r, zlim=c(0,400))

You could do

x <- clamp(r, 0, 400)
plot(x)