[R-sig-Geo] Spatial data interpolation on R
Robert J. Hijmans
r.hijmans at gmail.com
Tue Jun 29 20:15:49 CEST 2010
Thiago,
I think a better approach would be to estimate the value for the sat
images at the stations' locations; and not the other way around, as
your are proposing.
A simple way to do that is bilinear interpolation of the sat image
values for the weather station locations.
If 'xyv' is your lon/lat/prec matrix and 'f' is a filename for one of
your sat images.
library(raster)
r <- raster(f)
res <- xyValues(r, xyv[,1:2], method='bilinear')
plot(res, xyv[,3])
..... and now analyze the difference between res and xyv[,3] data
taking spatial autocorrelation into account
Nevertheless, if you insist on interpolating the weather station data,
you could do that with a spline
library(fields)
tps <- Tps(xyv[,1:2], xyv[,3])
p <- raster(r)
p <- interpolate(p, tps)
plot(p, r)
In the end, the best approach to obtaining a raster of the rainfall
data, if that is what you are after, would probably be a hybrid where
the sat image is use as an independent variable (covariate) in the
spline (or other interpolation method).
Robert
On Tue, Jun 29, 2010 at 8:59 AM, Don MacQueen <macq at llnl.gov> wrote:
> If you are willing to do simple interpolation, i.e., ignoring any spatial
> correlation, you could look at the interp() function, which is in the akima
> package. Even if you need to incorporate spatial correlation, starting with
> the interp() function would probably serve as a good way to get started
> learning R. The help page for interp() has some examples.
>
> Here's an excerpt from the help page for the interp() function:
>
> interp package:akima R Documentation
>
> Gridded Bivariate Interpolation for Irregular Data
>
> Description:
>
> These functions implement bivariate interpolation onto a grid for
> irregularly spaced input data. Bilinear or bicubic spline
> interpolation is applied using different versions of algorithms
> from Akima.
>
>
> Install the akima package using the R console GUI (Mac or Windows) or the
> install.packages() function (linux).
>
> Then there's the question of coordinate systems. interp() assumes cartesian
> coordinates, but lat/long is not cartesian. If your site is too large, you
> shouldn't ignore this, so you will have to learn how to project from
> lat/long to UTM or other appropriate local coordinate system. For this, I
> use the spTransform() function in the rgdal package. Looking on the CRAN
> website, it appears there is a Windows binary for rgdal; for the other
> platforms (I use Mac), it can be more challenging. Converting your data into
> a "spatial" class object, so that it can be projected, will be a challenge
> at first.
>
> Gettng the book that Mark Connolly mentioned would help a lot.
>
> -Don
>
>
> At 10:20 AM -0700 6/2/10, Thiago Veloso wrote:
>>
>> Content-Type: text/plain
>> Content-Disposition: inline
>> Content-length: 937
>>
>> Dear R colleagues!
>> I´d like to start my participation in this list by describing my current
>> problem: inside my area of study I need to compare precipitation data from
>> two different sources: both station (total of 86) and a grid (at 8km) of
>> satellite estimates.
>> My specific objective is to interpolate the station data into a regular
>> grid in the same resolution of the satellite estimates, preferentially
>> having control of the spatial domain (lat/lon coordinates). As far as I know
>> this is the correct way of making such comparison.
>> Could anybody please point directions to perform this task using R? I´m
>> such a beginner that I don´t even know if
>> there´s a package designed to create regular grids from "random" data
>> (interpolating by kriging or other technique). Usage examples would be
>> welcomed as well!
>> Thanks in advance,
>> Thiago.
>>
>>
>>
>> [[alternative HTML version deleted]]
>>
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo at stat.math.ethz.ch
>> https://*stat.ethz.ch/mailman/listinfo/r-sig-geo
>
>
> --
> --------------------------------------
> Don MacQueen
> Environmental Protection Department
> Lawrence Livermore National Laboratory
> Livermore, CA, USA
> 925-423-1062
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
More information about the R-sig-Geo
mailing list