How to "smoothen" a geodata set in R

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How to "smoothen" a geodata set in R

Tariq
Hello, I'm new to this list. Sorry if my question or parts of it already came up before.

For my research in geostatistics, I am working with large sets of data in R (basically large matrices containing discrete x and y coordinates and a value for a certain parameter). These sets are obtained by kriging. The operation I'd like to perform is smoothen the output data set. I want to do it by adding each data point and its 8 surrounding points and dividing this by nine (gives an average), and then replacing each element in the matrix with the result.

Question 1: is there a way to address the parameter value of a single element (for example, the value for element [x=452, y=682] inside the matrix) and perform an operation on it in R?
Question 2: is there a way to programm R into a loop, so that the same operation can be performed on all elements inside the matrix?
Question 3: is it a problem if my data is geodata (made with the geoR library)?
Reply | Threaded
Open this post in threaded view
|

Re: How to "smoothen" a geodata set in R

Daniel Malter
To answer your questions:

Yes, yes, and probably no. You will have to pick up any introductory manual of R where questions 1 and 2 will be discussed.

For 1: you index x as in x[452,682]. For 2: there are ways to write (and avoid) loops in R (e.g. for or while loops). Often avoidance is preferable because R is not very fast looping. For 3: I cannot say for sure, but as long as you data is in matrix format or something that can be coerced to it, no.

Daniel

Tariq wrote
Hello, I'm new to this list. Sorry if my question or parts of it already came up before.

For my research in geostatistics, I am working with large sets of data in R (basically large matrices containing discrete x and y coordinates and a value for a certain parameter). These sets are obtained by kriging. The operation I'd like to perform is smoothen the output data set. I want to do it by adding each data point and its 8 surrounding points and dividing this by nine (gives an average), and then replacing each element in the matrix with the result.

Question 1: is there a way to address the parameter value of a single element (for example, the value for element [x=452, y=682] inside the matrix) and perform an operation on it in R?
Question 2: is there a way to programm R into a loop, so that the same operation can be performed on all elements inside the matrix?
Question 3: is it a problem if my data is geodata (made with the geoR library)?