[R] DEM calculation

Lars Claussen
Thu, 02 Jun 2005 08:56:13 -0000

Hello R-World,

i am trying to calculate data for a DEM (Digital Elavation Model) which i
also want to plot in R. i have the coordinates for the lower left corner
which look something like this:

x<-42,2
y<-50,5

besides i have the cellsize of the grid, which is:

z<-1,1

what i do is to calculate the corrdinates of the cells to the right and top,
what i can do by specifying the number of rows and columns. these are
j<-1:805 (columns)
i<-1:616 (rows)

well, to calculate them seperatly is easy:

r<-x+(i-1)*z
h<-y+(j-1)*z

but i can't get it straight how to create a data frame with two rows, one
for the x- the other for the y-coordinate. The problem is, that lots of
values have to be repeated as every  first row x-coordinate has the same
y-coordinate and so on.

finally it should look like this:

x            y
42,2   50,5
43,3   50,5
44,4   50,5
45,5   50,5
 .         .
 .         .
42,2   51,5
43,3   51,5
44,3   51,5

any suggestion? thanks in advance, Lars Claussen