[Gstat-info] Kriging results not smooth
Edzer Pebesma
edzer.pebesma at uni-muenster.de
Sun Mar 22 21:49:41 CET 2009
Smoothing here means that the interpolated surface will no longer pass
through the observations. Where your prediction locations coincide with
observation locations, it becomes discontinuous, my feeling is that this
is in your case true as well, going from one grid to another.
About the positive definiteness: if your coordinates are long/lat, how
do you compute distances between points? Euclidian does not give the
right values; in your script below it will compute great circle
distances. Using these distances, many variogram models are no longer
positive definite. You may want to reproject your data using spTransform
in package rgdal. For questions regarding that (or this), you may want
to move to the r-sig-geo mailing list.
--
Edzer
Greg King wrote:
> Thanks, would you care to enlighten me as to what this would look like?
> Apologies if this is a very simple question, I am just getting back into
> statistical modelling. My understanding is that a nugget should be used if
> a variogram fit does not intercept at the origin - which is not the case
> with my data. As for the positive definite question, I'm afraid I don't
> understand that aspect - please feel free to point me in the direction of a
> primer.
>
> Greg
>
> On Sun, Mar 22, 2009 at 5:02 PM, Edzer Pebesma <
> edzer.pebesma at uni-muenster.de> wrote:
>
>
>> If you want more smooth output, try adding a nugget to your variogram.
>>
>> As you're interpolating in long/lat, you should also worry about your
>> variogram model being not positive definite when using spherical
>> distance measures.
>> --
>> Edzer
>>
>> Greg King wrote:
>>
>>> Hi,
>>>
>>> I'm performing ordinary kriging on a fairly simple data set (attached in
>>> testOut.csv). My objective is to krig wind data from a 0.5x0.5 degree
>>> lat/lon grid to a higher resolution 0.125x0.125 lat/lon grid. I have the
>>> following code up and running to interpolate the u component ugrd_0:
>>>
>>> library(gstat)
>>>
>>> # Read u and v component wind data from a 0.5 x 0.5 degree resolution
>>> latitude/longitude grid
>>> wind<-read.csv(file="/Users/greg/temp/testOut.csv",head=TRUE,sep=",")
>>> coordinates(wind) <- ~ lat+lon
>>> proj4string(wind) <- CRS("+init=epsg:4326")
>>>
>>> # Prepare new 0.125 degree resolution grid
>>> lat.range <- as.integer(range(wind at coords[,1]))
>>> lon.range <- as.integer(range(wind at coords[,2]))
>>> grd <- expand.grid(lat=seq(from=lat.range[1], to=lat.range[2], by=0.125),
>>> lon=seq(from=lon.range[1], to=lon.range[2], by=0.125) )
>>> coordinates(grd) <- ~ lat+lon
>>> gridded(grd) <- TRUE
>>> proj4string(grd) <- CRS("+init=epsg:4326")
>>>
>>> # Create gstat object
>>> g <- gstat(id="ugrd_0", formula=ugrd_0 ~ 1, data=wind)
>>> # Create variogram model
>>> v.fit <- fit.variogram(variogram(g) ,vgm(model="Lin") )
>>> # Predict values
>>> p <- predict(g, model=v.fit, newdata=grd)
>>>
>>> # Visualise
>>> image(p, col=terrain.colors(20))
>>>
>>> However, the results it produces are not very smooth (see attached
>>> output.png), with the original data points being very apparent. Playing
>>> around with different models does not appear to make a difference. Are
>>> there any suggestions as to what I might be missing here?
>>>
>>> Thanks in advance,
>>>
>>> Greg
>>>
>>>
>>>
>>> ------------------------------------------------------------------------
>>>
>>> ------------------------------------------------------------------------
>>>
>>> _______________________________________________
>>> Gstat-info mailing list
>>> Gstat-info at geo.uu.nl
>>> http://mailman.geo.uu.nl/mailman/listinfo/gstat-info
>>>
>>>
>> --
>> Edzer Pebesma
>> Institute for Geoinformatics (ifgi), University of Münster
>> Weseler Straße 253, 48151 Münster, Germany. Phone: +49 251
>> 8333081, Fax: +49 251 8339763 http://ifgi.uni-muenster.de/
>> http://www.springer.com/978-0-387-78170-9 e.pebesma at wwu.de
>>
>>
>>
>
>
--
Edzer Pebesma
Institute for Geoinformatics (ifgi), University of Münster
Weseler Straße 253, 48151 Münster, Germany. Phone: +49 251
8333081, Fax: +49 251 8339763 http://ifgi.uni-muenster.de/
http://www.springer.com/978-0-387-78170-9 e.pebesma at wwu.de
More information about the Gstat-info
mailing list