To get a feeling how the R-stats language works, we start GRASS/Spearfish for our sample session and reset GRASS to default settings, then we launch R within the GRASS terminal. A couple of commands are indicated:
grass60 g.region -dp R > library(spgrass6) > G <- gmeta6()
The above commands load the interface extension and then the GRASS environment into the R session. The next command shows the environment settings:
> str(G)
Now we load a GRASS raster map into R:
> geology <- readCELL6sp("geology")
> summary(geology)
> str(geology)
Since we are using GIS data, we want to look at the map:
> image(geology, "geology", col = terrain.colors(10))
To add a legend, we first control the number of classes in the geology map, then display the legend:
> system("r.info -r geology")
> legend(c(590000, 605000), c(4912570, 4913850),
legend = 1:9, fill = terrain.colors(10),
cex = 0.8, bty = "n", horiz = TRUE)
> q()
The new R/GRASS6 interface is subject to change. To keep this tutorial short, we suggest further reading elsewhere for geostatistics with R-stats. Links can be found in the Applications/Geostatistics section of the GRASS Web site.