[R] 3D-plots of 2D-grids
dwinsemius at comcast.net
Thu Feb 14 17:54:48 CET 2013
On Feb 14, 2013, at 8:05 AM, jas wrote:
> calc_ext3.asc <http://r.789695.n4.nabble.com/file/n4658564/calc_ext3.asc
> I supplied a small extent of the grid, that I am trying to
> visualize. It s a
> ascii-grid with 800 cells. My goal is to display the Grid-Values as
> z-variable. The point that I dont understand, is what is my input as
> x and
> y-Variable in the persp-function? Do I have to make 8 vectors with 100
> entries and plot them individually?
> Your help is greatly appreciated,
> pop.mat <- as.matrix(pop.grid) # order is not right here already
> z <- pop.mat
> x <- 1:nrow(z)
> y <- 1:nrow(z)
> persp(x,y,z, phi=30, border=NA)
> # Error n persp.default(x, y, z, phi = 30, border = NA) :
> invalid 'z' Argument
I copied the space separated data from that webpage into my clipboard
and executed this:
grd <- matrix( scan(), ncol=40, nrow=20)
# and pasted my clipboard
is.na(grd ) <- grd == -9999 # use a proper R missing value
# num [1:20, 1:40] NA NA NA NA NA ...
Alternatively you could have used read.table from that file with skip =6
The image looks rather disjointed and I'm hoping that lack of
continuity is an artifact of extracting only a portion of the data.
> View this message in context: http://r.789695.n4.nabble.com/3D-plots-of-2D-grids-tp4658517p4658564.html
> Sent from the R help mailing list archive at Nabble.com.
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
David Winsemius, MD
Alameda, CA, USA
More information about the R-help