# How to interpolate point value using kriging method with R and GRASS 6

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

## ORDINARY KRIGING IN R WITH GRASS6 DATA

Of all the methods we tried this is the most easy and (I suppose) exact too:

You have to have in your library the packages "gstat" and "spgrass6", you can download this last one directly from R using the command "install.packages". In GRASS we have a vector file named "giaciture_cat_clean3" and we want to do a prediction on this data... these are the commmands:

enter in R from GRASS and digit:

```>library(spgrass6)
>giaciture <- getSites6sp("giaciture_cat_clean3") #get vector points as SpatialPointsDataFrame
>class(giaciture) #shows the class of "giaciture" (SpatialPointsDataFrame)
>G <- gmeta6() #get region from GRASS to R
```

now if you want you can continue to work in R from GRASS or not...

```>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)) #create a grid from the region settings of GRASS, it is very important to have square cells, so you can set the region settings of GRASS or you can give directly square dimensions using the values: e.g."cells.dim=c(50,50)"
>mask_SG <- SpatialGridDataFrame(grd,data=list(k=rep(1,G\$cols*G\$rows)),proj4string=CRS(G\$proj4)) #create a SpatialGridDataFrame