2

I have an elevation model plotted in R Code:

library(raster)
data(volcano)
r <- raster(volcano)
plot(r, col = topo.colors(20))

Plot: enter image description here

how can we retrieve the values ​​of the intervals in the legend, that is, in the example-->100,120,140,160,180

zina_GIS
  • 763
  • 1
  • 14
  • 22
  • 1
    Out of curiosity, what do you hope to do with the intervals? +1 for a reproducible example. – Aaron Oct 21 '14 at 12:53
  • I want to made ​​for my application ploter the upper variable, above 180 and below 100 that's just an example I want to get an idea across. – zina_GIS Oct 21 '14 at 13:12
  • 2
    Are you interested in defining the intervals yourself, or do you need to stay with the default intervals? Is this what you are looking to do?: http://gis.stackexchange.com/a/17352/8104 – Aaron Oct 21 '14 at 14:00
  • I am looking to define them! how I can get the values ​​of the interval? in the example we have given color for each known interval through the pads. but I want to automatically extract values​​. I do not know if I'm clear or I give more precision? – zina_GIS Oct 21 '14 at 14:10
  • 1
    oupss ,"I meant in my last comment, I'm not looking to define them" I want to extract them,sorry! – zina_GIS Oct 21 '14 at 15:06

1 Answers1

2

The legend is a summary of the raster values. Therefore, you will need to extract the pertinent raster values. This should do it:

library(raster)
data(volcano)
r = raster(volcano)

min = minValue(r)
max = maxValue(r)
l = c(min:max)
result = l[l %% 20 == 0]

> result
[1] 100 120 140 160 180
Aaron
  • 51,658
  • 28
  • 154
  • 317