[R] 3D-plots of 2D-grids

David Winsemius dwinsemius at comcast.net
Thu Feb 14 12:18:01 CET 2013


On Feb 14, 2013, at 1:10 AM, jas wrote:

>
> Hello everybody,
>
> I have an Ascii-grid (100x100m) with population density over  
> Switzerland
> (local coordinations system, CH LV03). Now I would like to have a nice
> graphic to present the data. I would like to make a plot that will  
> show the
> density as the z-variable and raise for example a stacking pillar  
> showing
> how high the density is in that hectare. I attached a map that's   
> similar to
> what I would like, to give you an idea incase I am not making myself  
> clear.
> <http://r.789695.n4.nabble.com/file/n4658517/Bildschirmfoto_2013-02-14_um_10.08.51.png 
> >
>
> Can you tell me how I can do this? I tried persp and persp3d, but  
> there the
> x and y-vectors have to be increasing values, where as the  
> coordinates in a
> grid don't necessarily increase for both x and y, as they follow the  
> line
> horizontally...
>

I thought you said you had a 'grid'  presumably with values at the  
intersections of the grid? That is the sort of input that persp will  
take. You would supply x=seq( ..., length=100), y= seq( ... ,  
length=100) and your 'grid' (which I assume is stored as a matrix) as  
z values. In fact if you just supply a matrix as the z value to persp  
you will get an automatic display, just not with the labels you might  
have hoped for.

-- 

David Winsemius, MD
Alameda, CA, USA



More information about the R-help mailing list