Sunday, 1 February 2015

raster - Preventing reflective surface in rasterVis


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.



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 seek some pointers.


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)


Answer



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


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...