10

I have been experimenting with digital terrain model files in ESRI ASCII grid raster format. Despite zero experience with this type of data I found it very easy to load into R, as per code below. The plot3D function from the rasterVis package defaults to a nice looking plot but the model is rather reflective. Given that it's supposed to be a landscape this shiny surface is not really appropriate. EDIT: I am looking for a more natural (if such a word can be used about a 3D rendering of a set of figures), matt, topological plot.

shiny

I imagine there must be ways around this but I have no experience using raster and would much appreciate some pointers. So my question is: how can I reduce or remove the reflectivity of the plot?

library(raster)
library(rgdal)
library(rasterVis)

foo <- raster(readGDAL("my.dtm.asc"))
plot3D(foo)
4

I did some tests and came up finding the ?rgl.material argument specular, which helped with the task.

See the example below:

library(raster)
library(rasterVis)

r = raster(volcano)

plot3D(r,lit=TRUE,specular="white") #white is default
plot3D(r,lit=TRUE,specular="black") #change specular to black

enter image description here

  • I have experimented with this and it definitely makes a better image. Thanks to yourself and @Jeffrey Evans for the education. – SlowLearner Jan 11 '14 at 13:58
2

You will need to pass arguments to plot3D that modify rgl display characteristics using arguments available in "rgl.material". I would start with "shininess" or "luminance". You would just specify the associated rgl.material arguments directly in plot3D.

plot3D(foo, zfac=2, shininess=10) 
  • <face-palm> I searched for shiny and shininess in the rasterVis docs, didn't occur to me to check the rgl docs! Setting shininess to its max value of 128 helps, but it's still reflective. Luminance seems to have no real effect and isn't explained in the docs? – SlowLearner Jan 9 '14 at 21:13
  • 1
    I tried it but was surprised by the result, so I wanted to check. It's... interesting, but not quite what I wanted for a realistic topological plot. I guess there is more to discover in terms of tweaking. – SlowLearner Jan 10 '14 at 10:50
1

I'm pretty new with r and the rasterVis package as well. One thing that I've found helpful is exploring different color palettes to see if you can find one that better fits what you're looking for (without having to go in and try to modify the colors to fit exactly what I want). For example I've tried:

plot3D(foo, col=terrain.colors(6))

With pretty decent results. You can also experiment with palettes from the RColorBrewer package some of which seem to be less shiny. e.g:

plot3D(foo, col=brewer.pal(9, 'YlOrRd'))

Hope this helps!

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.