Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am trying to insert an RColorBrewer palette to visualize an elevation raster in R using the rasterVis function plot3D. The rasterVis reference document shows the following parameters:

plot3D(x, maxpixels=100000, zfac=1, drape=NULL, col, rev=FALSE, adjust=TRUE, ...)

However, when I use col= I get the following error:

Error in col(zlen) : 
  a matrix-like object is required as argument to 'row/col'

When I use color= I get:

Error in f(...) : 
  formal argument "color" matched by multiple actual arguments

I've also tried this:

color.palette = brewer.pal(11, "PRGn")

which renders the 3D-plot, but uses the default color palette.

This article does not provide a solution. Nor have I found anything useful on GISSE or StackOverflow:

Any suggestions, assistance clarifying the errors, or input is much appreciated.

share|improve this question
    
Mike - think you should be targeting here: stackoverflow.com/questions/tagged/r –  Andrew Tice Nov 6 '13 at 23:07
    
....dur... ignore my comment! Just read the bottom line of your question. –  Andrew Tice Nov 6 '13 at 23:09
add comment

1 Answer

up vote 2 down vote accepted

From ?plot3D:

Arguments

...

col: A color palette generating function such as rainbow, heat.colors, and topo.colors, or one or your own making

You can use colorRampPalette to generate your own palette function from given colors, e.g.

library("rasterVis")
library("RColorBrewer")
data(volcano)
r <- raster(volcano)
extent(r) <- c(0, 610, 0, 870)
plot3D(r, drape=NULL, zfac=2, col=colorRampPalette(brewer.pal(11, "PRGn")))
share|improve this answer
    
that did it! thanks @rcs, I'm still an R novice. –  mikeLdub Nov 7 '13 at 13:56
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.