ok, <br>From your answers, I&#39;ve tried to play with the SpatialPointsDataFrame object imported from GRASS to fit the gstat krige function requirements. Basic idea seemed to work with the &quot;data&quot; attribute of the imported object, adding the missing coordinates columns : <br>

<br>&gt;sitesR &lt;- readVECT6(&quot;grass_sites&quot;)<br>&gt;class(sitesR)<br>
&gt; [1] &quot;SpatialPointsDataFrame&quot;<br>&gt; d = attr(sitesR,&quot;data&quot;)<br>&gt;d<br><br>           site value cat<br>1           Ail      81.80   1<br>2     All      38.50   2<br>3     Arg     103.50   3<br>

4           Avb      52.50   4<br>...<br><br>&gt; sitesR$x &lt;- coordinates(sitesR)[,1]<br>&gt;sitesR$y &lt;- coordinates(sitesR)[,2]<br>&gt; d = attr(sitesR,&quot;data&quot;)<br>&gt; class(d)<br>[1] &quot;data.frame&quot;<br>

&gt; d<br>           site value cat        x       y<br>1           Ail      81.80   1 825094.9 6796083<br>2     All      38.50   2 758780.4 6851508<br>3     Arg     103.50   3 818973.3 6796125<br>4           Avb      52.50   4 775136.0 6877271<br>

...<br><br>&gt; coordinates(d) = ~x+y<br>&gt; attr(d, &quot;proj4string&quot;) &lt;-CRS(G$proj4)<br><br>&gt;G &lt;- gmeta6()<br>&gt;grd &lt;- gmeta2grd()<br>&gt;slot(grd, &quot;cellsize&quot;) &lt;- c(1000, 1000)<br>&gt;data &lt;- data.frame(list(k=rep(1,(floor(G$cols)*floor(G$rows)))))<br>

&gt; mask_SG &lt;- SpatialGridDataFrame(grd, data=data, CRS(G$proj4))<br><br><br>&gt;predictors = &quot;x+y&quot;<br>
&gt;kriging_result = autoKrige(as.formula(paste(column,&quot;~&quot;,predictors)), d, mask_SG)<br><br>Result was : <br><br>Error in gstat.formula.predict(d$formula, newdata, na.action = na.action,  : <br>  NROW(locs) != NROW(X): this should not occur<br>

Warning messages:<br>1: &#39;newdata&#39; had 7900 rows but variable(s) found have 73 rows <br>2: &#39;newdata&#39; had 7900 rows but variable(s) found have 73 rows <br><br>1)do you think this approach could be successful?<br>

2)If so, can you help me with this error? <br><br>Mathieu<br><br><div class="gmail_quote">2009/6/26 Edzer Pebesma <span dir="ltr">&lt;<a href="mailto:edzer.pebesma@uni-muenster.de" target="_blank">edzer.pebesma@uni-muenster.de</a>&gt;</span><br>

<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><br>
<br>
Roger Bivand wrote:<br>
&gt; On Thu, 25 Jun 2009, Edzer Pebesma wrote:<br>
&gt;<br>
&gt;&gt; Mathieu, that could very well be the case. Note that x+y do not<br>
&gt;&gt; &quot;generally&quot; refer to x- and y-coordinates, but are the actual names of<br>
&gt;&gt; the coordinates (or something else). From your example I cannot find out<br>
&gt;&gt; whether the coordinates are named x and y. In addition, they should have<br>
&gt;&gt; identical names in sitesR and mask_SG.<br>
&gt;<br>
&gt; Yes, it is beginning to look like the names in mask_SG, isn&#39;t it? Do<br>
&gt; you have a view on whether degree= should be mandatory, or does the<br>
&gt; infrastructure recognise coordinate RHS variables and rescale them<br>
&gt; automatically (I doubt the latter)? Why do users use trend variables<br>
&gt; in this way - the range of values in the (X&#39;X) matrix becomes enormous<br>
&gt; with the usual metre metric for coordinates?<br>
</div>Another question we could ask (ourselves) is why in R we allow users to<br>
give their coordinates the names they like. I remember that for that<br>
sole reason (need to rename) I added the function<br>
<br>
coordnames(x) = c(&quot;u&quot;, &quot;v&quot;)<br>
<br>
to sp. In case they&#39;re called &quot;lon&quot; and &quot;lat&quot;, they also don&#39;t change<br>
name after projection. But maybe I talk too much with people worrying<br>
about semantics, these days. ;-)<br>
--<br>
<font color="#888888">Edzer<br>
</font><div><div></div><div>&gt;<br>
&gt; Roger<br>
&gt;<br>
&gt;&gt;<br>
&gt;&gt; Best regards,<br>
&gt;&gt; --<br>
&gt;&gt; Edzer<br>
&gt;&gt;<br>
&gt;&gt; mathieu grelier wrote:<br>
&gt;&gt;<br>
&gt;&gt; Dear all,<br>
&gt;&gt; I am trying to achieve universal kriging with GRASS and R through<br>
&gt;&gt; spgrass6<br>
&gt;&gt; package.<br>
&gt;&gt; Maybe you could help me to find the right R syntax.<br>
&gt;&gt; As in the gstat doc, the polynomial I try to use for now is &quot;x+y&quot;<br>
&gt;&gt;<br>
&gt;&gt;&gt; Dear all,<br>
&gt;&gt;&gt; I am trying to achieve universal kriging with GRASS and R through<br>
&gt;&gt;&gt; spgrass6<br>
&gt;&gt;&gt; package.<br>
&gt;&gt;&gt; Maybe you could help me to find the right R syntax.<br>
&gt;&gt;&gt; As in the gstat doc, the polynomial I try to use for now is &quot;x+y&quot;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; In R, with automap package, this works :<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; data(meuse)<br>
&gt;&gt;&gt;&gt; coordinates(meuse) = ~x+y<br>
&gt;&gt;&gt;&gt; data(meuse.grid)<br>
&gt;&gt;&gt;&gt; gridded(meuse.grid) = ~x+y<br>
&gt;&gt;&gt;&gt; column = &quot;zinc&quot;<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt; ##Ordinary kriging :<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; predictors = &quot;1&quot;<br>
&gt;&gt;&gt;&gt; autoKrige(as.formula(paste(column,&quot;~&quot;, predictors)), meuse,<br>
&gt;&gt;&gt;&gt; meuse.grid)<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt; ##Universal kriging :<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; predictors = &quot;x+y&quot;<br>
&gt;&gt;&gt;&gt; autoKrige(as.formula(paste(column,&quot;~&quot;, predictors)), meuse,<br>
&gt;&gt;&gt;&gt; meuse.grid)<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; But using spgrass6, it becomes (some steps have been skipped):<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; sitesR &lt;- readVECT6(&quot;grass_sites&quot;)<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt; ...<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; mask_SG &lt;- SpatialGridDataFrame(grd, data=data, CRS(G$proj4))<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt; ...<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; ##Ordinary kriging =&gt; WORKS:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; predictors = &quot;1&quot;<br>
&gt;&gt;&gt;&gt; kriging_result = autoKrige(as.formula(paste(column,&quot;~&quot;,predictors)),<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt; sitesR, mask_SG)<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; ##Universal kriging =&gt; ERROR:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; predictors = &quot;x+y&quot;<br>
&gt;&gt;&gt;&gt; kriging_result = autoKrige(as.formula(paste(column,&quot;~&quot;,predictors)),<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt; sitesR, mask_SG)<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; Error in eval(expr, envir, enclos) : &quot;x&quot; object not found<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Why can&#39;t we use the x an y columns here?<br>
&gt;&gt;&gt; Maybe it is because the meuse and sites R data.frames don&#39;t have the<br>
&gt;&gt;&gt; same<br>
&gt;&gt;&gt; structure ?<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; class(meuse)<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt; [1] &quot;data.frame&quot;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; attributes(meuse)<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt; $names<br>
&gt;&gt;&gt;  [1] &quot;x&quot;       &quot;y&quot;       &quot;cadmium&quot; &quot;copper&quot;  &quot;lead&quot;    &quot;zinc&quot;    &quot;elev&quot;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; class(sitesR)<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt; [1] &quot;SpatialPointsDataFrame&quot;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; attributes(sitesR)<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt; $bbox<br>
&gt;&gt;&gt; ...<br>
&gt;&gt;&gt; $proj4string<br>
&gt;&gt;&gt; ...<br>
&gt;&gt;&gt; $coords<br>
&gt;&gt;&gt; ...<br>
&gt;&gt;&gt; $data<br>
&gt;&gt;&gt;            site value cat        x       y<br>
&gt;&gt;&gt; 1Ai      81.80   1 825094.9 6796083<br>
&gt;&gt;&gt; 2     Al      38.50   2 758780.4 6851508<br>
&gt;&gt;&gt; 3     Ar     103.50   3 818973.3 6796125<br>
&gt;&gt;&gt; 4           Av      52.50   4 775136.0 6877271<br>
&gt;&gt;&gt; ...<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; ------------------------------------------------------------------------<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; _______________________________________________<br>
&gt;&gt;&gt; grass-stats mailing list<br>
&gt;&gt;&gt; <a href="mailto:grass-stats@lists.osgeo.org" target="_blank">grass-stats@lists.osgeo.org</a><br>
&gt;&gt;&gt; <a href="http://lists.osgeo.org/mailman/listinfo/grass-stats" target="_blank">http://lists.osgeo.org/mailman/listinfo/grass-stats</a><br>
&gt;&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;<br>
<br>
--<br>
</div></div><div><div></div><div>Edzer Pebesma<br>
Institute for Geoinformatics (ifgi), University of Münster<br>
Weseler Straße 253, 48151 Münster, Germany. Phone: +49 251<br>
8333081, Fax: +49 251 8339763 <a href="http://ifgi.uni-muenster.de/" target="_blank">http://ifgi.uni-muenster.de/</a><br>
<a href="http://www.springer.com/978-0-387-78170-9" target="_blank">http://www.springer.com/978-0-387-78170-9</a> <a href="mailto:e.pebesma@wwu.de" target="_blank">e.pebesma@wwu.de</a><br>
<br>
</div></div></blockquote></div><br>