Search code examples
rgisvisualizationrasterr-raster

How to change Scale in raster plot?


Complete R noob, need help plotting a raster with a good scale.

rast <- raster("accessibility.tif")
pal <- colorRampPalette(c("green","red"))
plot(rast, 
     col = pal(10),
     zlim = c(0,180))

This is what the output is: Mentioning zlim cuts out points

See, all the values after 180 are simply not plot.
It's like they're cut out of the scale.
This wont do as there are a good minority of values after 180 that go till 3500.

I don't want the scale to go from 0 - 180,
I need it to go from 0 - 180+
I want all of those points to be plot in Red too.

Thank You for your help


Solution

  • You can do something like this:

    library(raster)
    rast <- raster("accessibility.tif")
    r <- clamp(rast, 0, 180) 
    pal <- colorRampPalette(c("green","red"))
    plot(r, col = pal(10))