[Gstat-info] Re: Gstat-info Digest, Vol 40, Issue 6
Edzer Pebesma
edzer.pebesma at uni-muenster.de
Mon Mar 30 08:12:51 CEST 2009
Is it possible that variab is of class character, or factor? This should
not be the case.
What exactly did you mean by "produce the variogram"? After which
command did you get an error?
--
Edzer
Greg King wrote:
> I'm trying to pass a character vector and data frame into a function
> that performs ordinary kriging. The function appears to pass the
> items in correctly, as I can get it to report the class of (or even
> print) the variables in the function call. However when used to
> produce the variogram, it fails.
>
> Here is the function:
>
> gks <- function(inLat,inLon,dframe,variab) {
> wind.grid <- expand.grid(lat=inLat, lon=inLon)
> coordinates(wind.grid) <- ~ lat+lon
> proj4string(wind.grid) <- CRS("+init=epsg:4326")
> print(class(variab))
> print(class(dframe))
> wind.vgm=variogram(variab~1,dframe)
> wind.fit=fit.variogram(wind.vgm, model=vgm(model="Lin"))
> wind.kriged=krige(variab~1,dframe,wind.grid,model=wind.fit,nmax=9)
>
> print(wind.kriged$var1.pred)
> }
>
> Here it the call of the function:
>
> gks(1,1,sset,columns[j])
>
> Here is the output showing that a character vector and dataframe have
> been passed in, but then the error that I don't understand...
>
> [1] "character"
> [1] "SpatialPointsDataFrame"
> attr(,"package")
> [1] "sp"
> Error: too many spatial dimensions: 162
> In addition: Warning messages:
> 1: In model.matrix.default(Terms, m) :
> variable 'variab' converted to a factor
> 2: NAs introduced by coercion
>
> Any pointers gratefully received. I'm new to creating functions in R,
> as you might have guessed.
>
> Thanks,
>
> Greg
>
> Pastebot <http://sf.net/projects/pastebot/> is powered by
> POE<http://poe.perl.org/>
> .
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> 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
More information about the Gstat-info
mailing list