[R] persp()

Rosario Garcia Gil M.Rosario.Garcia at slu.se
Thu Aug 4 02:58:28 CEST 2011


Hello

I am trying to draw a basic black and white map of two European countries.

After searching some key words in google and reading many pages I arrived to the conclusion that persp() could be used to draw that map.

I have prepared three small example files, which are supposed to be the files required for running that function.

xvector is a vector with the longitudes
yvector is a vector with the latitudes
zmatrix is supposed to the height, but since I only need a flat map I just gave the value 1 to each of the entries of the matrix (I am not sure this is correct though).

The first question for me when using persp() is that x and y values should be in increasing values (following the instructions), but I understand that the coordinates x and y are actually pairs of values (longitude/latitude pairs of values) and if I order them in ascending order both then the pairing is gone. I guess I am totally lost!

Still even if I try to run persp() by ordering in ascending value x and y values (even if it does not make sense for me) I still get this message:

<-  persp(xvector,yvector,zmatrix,theta=-40,phi=30)
Error in persp.default(xvector, yvector, zmatrix, theta = -40, phi = 30) : 
  increasing 'x' and 'y' values expected

Any help is wellcome. Is there any other better function to draw a flat map (2D), also example of the imput files is wellcome. Thanks in advance.
Rosario



More information about the R-help mailing list