

Hello everybody,
I have an Asciigrid (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 zvariable 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. Can you tell me how I can do this? I tried persp and persp3d, but there the x and yvectors 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...
Your help would be greatly appreciated :),
Thank you
jacqueline


On Feb 14, 2013, at 1:10 AM, jas wrote:
>
> Hello everybody,
>
> I have an Asciigrid (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 zvariable 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_20130214_um_10.08.51.png
> >
>
> Can you tell me how I can do this? I tried persp and persp3d, but
> there the
> x and yvectors 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
______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


calc_ext3.ascI supplied a small extent of the grid, that I am trying to visualize. It s a asciigrid with 800 cells. My goal is to display the GridValues as the zvariable. The point that I dont understand, is what is my input as x and yVariable in the perspfunction? Do I have to make 8 vectors with 100 entries and plot them individually?
Your help is greatly appreciated,
jas
pop.grid
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


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
> asciigrid with 800 cells. My goal is to display the GridValues as
> the
> zvariable. The point that I dont understand, is what is my input as
> x and
> yVariable in the perspfunction? Do I have to make 8 vectors with 100
> entries and plot them individually?
>
> Your help is greatly appreciated,
>
> jas
>
> pop.grid
> 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
str(grd)
# num [1:20, 1:40] NA NA NA NA NA ...
persp(z=grd)
image(grd)
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.

David.
David Winsemius, MD
Alameda, CA, USA
______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


Hello David,
thanks again for your reply.
Two things remain unclear. That the data is disjointed is ok, as there are only values in hectares, where there are actually buildings and stuff, forest/nature is NA.
The prespscan that I get from persp(grd) has no similarity to the image in 2d. My guess is that the order and regularity in the data somehow gets lost in the process of making the matrix?!
The gridextraction that I uploaded contains 40x20 cells. if its a bigger grid with 7million cells, does it still work the same way or can the vectors only be a maximum of 100 cells?
Thank you for your help
jas


On Feb 15, 2013, at 1:14 AM, jas wrote:
> Hello David,
> thanks again for your reply.
>
> Two things remain unclear. That the data is disjointed is ok, as there are
> only values in hectares, where there are actually buildings and stuff,
> forest/nature is NA.
>
> The prespscan that I get from persp(grd) has no similarity to the image in
> 2d. My guess is that the order and regularity in the data somehow gets lost
> in the process of making the matrix?!
I think the disjointedness is the problem. There are many values where there is no adjacent value in one direction of another and so no tessellation can be formed. If you look at the image result and note the places where there are "solid values" in both x and y directions I think the overall patterns match up. The image result is more faithful to the data.
>
> The gridextraction that I uploaded contains 40x20 cells. if its a bigger
> grid with 7million cells, does it still work the same way or can the vectors
> only be a maximum of 100 cells?
Might be a performance problem although I don't think it is theoretically impossible. An 8000 x 8000 matrix consumed my full CPU resources and essentially locked up my session. I'm in the process of deciding when to halt it.
Are you aware that there are far more knowledgeable persons than I that hang out at the RSIGGeo list?

David
David Winsemius
Alameda, CA, USA
______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


Compare:
persp(matrix(c(1,1,NA,NA,
1,1,NA,NA,
1,NA,NA,NA,
1,NA,NA,1), 4,4), zlim=c(0,2))
persp(matrix(c(1,1,0,0,
1,1,0,0,
1,0,0,0,
1,0,0,1), 4,4), zlim=c(0,2))

David.
On Feb 15, 2013, at 12:01 PM, David Winsemius wrote:
>
> On Feb 15, 2013, at 1:14 AM, jas wrote:
>
>> Hello David,
>> thanks again for your reply.
>>
>> Two things remain unclear. That the data is disjointed is ok, as there are
>> only values in hectares, where there are actually buildings and stuff,
>> forest/nature is NA.
>>
>> The prespscan that I get from persp(grd) has no similarity to the image in
>> 2d. My guess is that the order and regularity in the data somehow gets lost
>> in the process of making the matrix?!
>
> I think the disjointedness is the problem. There are many values where there is no adjacent value in one direction of another and so no tessellation can be formed. If you look at the image result and note the places where there are "solid values" in both x and y directions I think the overall patterns match up. The image result is more faithful to the data.
>
>>
>> The gridextraction that I uploaded contains 40x20 cells. if its a bigger
>> grid with 7million cells, does it still work the same way or can the vectors
>> only be a maximum of 100 cells?
>
> Might be a performance problem although I don't think it is theoretically impossible. An 8000 x 8000 matrix consumed my full CPU resources and essentially locked up my session. I'm in the process of deciding when to halt it.
>
> Are you aware that there are far more knowledgeable persons than I that hang out at the RSIGGeo list?
>
> 
> David
>
>>
>> Thank you for your help
>> jas
>>
>>
>>
>> 
>> View this message in context: http://r.789695.n4.nabble.com/3Dplotsof2Dgridstp4658517p4658639.html>> Sent from the R help mailing list archive at Nabble.com.
>>
>> ______________________________________________
>> [hidden email] mailing list
>> https://stat.ethz.ch/mailman/listinfo/rhelp>> PLEASE do read the posting guide http://www.Rproject.org/postingguide.html>> and provide commented, minimal, selfcontained, reproducible code.
>
> David Winsemius
> Alameda, CA, USA
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/rhelp> PLEASE do read the posting guide http://www.Rproject.org/postingguide.html> and provide commented, minimal, selfcontained, reproducible code.
David Winsemius
Alameda, CA, USA
______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.

