[GRASSLIST:9963] Re: R, kriging and grass6

Kirk R. Wythers kwythers at umn.edu
Mon Jan 23 16:40:15 EST 2006


Roger,

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?


  Kirk
On Jan 23, 2006, at 2:09 PM, Roger Bivand wrote:

> This is the dense version, feedback welcome!
>
> library(spgrass6) # load package running within GRASS 6
> meuse <- getSites6sp("meuse") # get vector points as
> SpatialPointsDataFrame
> class(meuse)
> G <- gmeta6() # get region
> grd <- GridTopology(cellcentre.offset=c(G$west+(G$ewres/2),
>   G$south+(G$nsres/2)), cellsize=c(G$ewres, G$nsres),
>   cells.dim=c(G$cols, G$rows))
> mask_SG <- SpatialGridDataFrame(grd, data=list(k=rep(1, G$cols*G 
> $rows)),
>   proj4string=CRS(G$proj4)) # create a SpatialGridDataFrame
> class(mask_SG)
> cvgm <- variogram(zinc~1, loc=~x+y, data=meuse, width=100,  
> cutoff=1000)
> efitted <- fit.variogram(cvgm, vgm(psill=1, model="Exp", range=100,
>   nugget=1))
> OK_pred <- krige(id="OK_pred", formula = zinc ~ 1, locations = ~ x  
> + y,
>   data = as(meuse, "data.frame"), newdata=mask_SG, model=efitted)
>   # make the kriging prediction
> names(OK_pred)
> writeRast6sp(OK_pred, "OK_pred", zcol = "OK_pred.pred", NODATA=-9999)
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/grass-user/attachments/20060123/1353b940/attachment.html


More information about the grass-user mailing list