<HTML><BODY DEFANGED_STYLE="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; ">Roger,<DIV><BR class="khtml-block-placeholder"></DIV><DIV>Thanks for putting this together. I do have a very basic question about getting the vector points from a GRASS vector to R. Can you roll this description back a couple of steps and start with a GRASS vector? Is this example based on the maas data?</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV> Kirk</DIV><DIV><DIV><DIV>On Jan 23, 2006, at 2:09 PM, Roger Bivand wrote:</DIV><BR class="Apple-interchange-newline"><BLOCKQUOTE type="cite"><P style="margin: 0.0px 0.0px 0.0px 0.0px"><FONT face="Helvetica" size="3" style="font: 12.0px Helvetica">This is the dense version, feedback welcome!</FONT></P> <P DEFANGED_STYLE="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px"><BR></P> <P style="margin: 0.0px 0.0px 0.0px 0.0px"><FONT face="Helvetica" size="3" style="font: 12.0px Helvetica">library(spgrass6) # load package running within GRASS 6</FONT></P> <P DEFANGED_STYLE="margin: 0.0px 0.0px 0.0px 0.0px"><FONT face="Helvetica" size="3" DEFANGED_STYLE="font: 12.0px Helvetica">meuse <- getSites6sp("meuse") # get vector points as<SPAN class="Apple-converted-space"> </SPAN></FONT></P> <P style="margin: 0.0px 0.0px 0.0px 0.0px"><FONT face="Helvetica" size="3" style="font: 12.0px Helvetica">SpatialPointsDataFrame</FONT></P> <P DEFANGED_STYLE="margin: 0.0px 0.0px 0.0px 0.0px"><FONT face="Helvetica" size="3" DEFANGED_STYLE="font: 12.0px Helvetica">class(meuse)</FONT></P> <P DEFANGED_STYLE="margin: 0.0px 0.0px 0.0px 0.0px"><FONT face="Helvetica" size="3" DEFANGED_STYLE="font: 12.0px Helvetica">G <- gmeta6() # get region</FONT></P> <P style="margin: 0.0px 0.0px 0.0px 0.0px"><FONT face="Helvetica" size="3" style="font: 12.0px Helvetica">grd <- GridTopology(cellcentre.offset=c(G$west+(G$ewres/2),<SPAN class="Apple-converted-space"> </SPAN></FONT></P> <P DEFANGED_STYLE="margin: 0.0px 0.0px 0.0px 0.0px"><FONT face="Helvetica" size="3" style="font: 12.0px Helvetica"><SPAN class="Apple-converted-space"> </SPAN>G$south+(G$nsres/2)), cellsize=c(G$ewres, G$nsres),</FONT></P> <P DEFANGED_STYLE="margin: 0.0px 0.0px 0.0px 0.0px"><FONT face="Helvetica" size="3" DEFANGED_STYLE="font: 12.0px Helvetica"><SPAN class="Apple-converted-space"> </SPAN>cells.dim=c(G$cols, G$rows))</FONT></P> <P DEFANGED_STYLE="margin: 0.0px 0.0px 0.0px 0.0px"><FONT face="Helvetica" size="3" style="font: 12.0px Helvetica">mask_SG <- SpatialGridDataFrame(grd, data=list(k=rep(1, G$cols*G$rows)),</FONT></P> <P DEFANGED_STYLE="margin: 0.0px 0.0px 0.0px 0.0px"><FONT face="Helvetica" size="3" DEFANGED_STYLE="font: 12.0px Helvetica"><SPAN class="Apple-converted-space"> </SPAN>proj4string=CRS(G$proj4)) # create a SpatialGridDataFrame</FONT></P> <P DEFANGED_STYLE="margin: 0.0px 0.0px 0.0px 0.0px"><FONT face="Helvetica" size="3" DEFANGED_STYLE="font: 12.0px Helvetica">class(mask_SG)</FONT></P> <P DEFANGED_STYLE="margin: 0.0px 0.0px 0.0px 0.0px"><FONT face="Helvetica" size="3" DEFANGED_STYLE="font: 12.0px Helvetica">cvgm <- variogram(zinc~1, loc=~x+y, data=meuse, width=100, cutoff=1000)</FONT></P> <P DEFANGED_STYLE="margin: 0.0px 0.0px 0.0px 0.0px"><FONT face="Helvetica" size="3" DEFANGED_STYLE="font: 12.0px Helvetica">efitted <- fit.variogram(cvgm, vgm(psill=1, model="Exp", range=100,<SPAN class="Apple-converted-space"> </SPAN></FONT></P> <P DEFANGED_STYLE="margin: 0.0px 0.0px 0.0px 0.0px"><FONT face="Helvetica" size="3" DEFANGED_STYLE="font: 12.0px Helvetica"><SPAN class="Apple-converted-space"> </SPAN>nugget=1))</FONT></P> <P style="margin: 0.0px 0.0px 0.0px 0.0px"><FONT face="Helvetica" size="3" style="font: 12.0px Helvetica">OK_pred <- krige(id="OK_pred", formula = zinc ~ 1, locations = ~ x + y,</FONT></P> <P DEFANGED_STYLE="margin: 0.0px 0.0px 0.0px 0.0px"><FONT face="Helvetica" size="3" DEFANGED_STYLE="font: 12.0px Helvetica"><SPAN class="Apple-converted-space"> </SPAN>data = as(meuse, "data.frame"), newdata=mask_SG, model=efitted)</FONT></P> <P style="margin: 0.0px 0.0px 0.0px 0.0px"><FONT face="Helvetica" size="3" DEFANGED_STYLE="font: 12.0px Helvetica"><SPAN class="Apple-converted-space"> </SPAN># make the kriging prediction</FONT></P> <P DEFANGED_STYLE="margin: 0.0px 0.0px 0.0px 0.0px"><FONT face="Helvetica" size="3" style="font: 12.0px Helvetica">names(OK_pred)</FONT></P> <P DEFANGED_STYLE="margin: 0.0px 0.0px 0.0px 0.0px"><FONT face="Helvetica" size="3" DEFANGED_STYLE="font: 12.0px Helvetica">writeRast6sp(OK_pred, "OK_pred", zcol = "OK_pred.pred", NODATA=-9999)</FONT></P> <P DEFANGED_STYLE="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px"><BR></P> </BLOCKQUOTE></DIV><BR></DIV></BODY></HTML>