GRASS 6 Tutorial: Difference between revisions

From GRASS-Wiki
Jump to navigation Jump to search
No edit summary
 
Line 17: Line 17:
while preserving the flexibility of traditional GRASS topological
while preserving the flexibility of traditional GRASS topological
tools. GRASS now also incorporates true 3-dimensional voxels in the
tools. GRASS now also incorporates true 3-dimensional voxels in the
[[http://grass.itc.it/gdp/nviz/index.html][NVIS]] visualization environment as well as a [[http://grass.itc.it/grass60/index.php][numerous enhancements]] to
[[http://grass.itc.it/gdp/nviz/index.html][NVIS]] visualization environment as well as [[http://grass.itc.it/grass60/index.php][numerous enhancements]] to
virtually every tool in the GRASS library.
virtually every tool in the GRASS library.



Revision as of 21:59, 20 May 2006

The Free Software/Open Source GIS GRASS 6 is fully operational and stable version for production use. This tutorial tries to give you a hand to familiarize yourself with the improved functionality, especially in the vector engine and attribute management. For further reading, see the references below.

Disclaimer: In case the examples described here do not work properly, you are kindly invited to send us further examples and/or code bugfixes/enhancements. Enjoy the WIKI!

This tutorial is intended for GRASS users who want to migrate from a previous release to the new GRASS Version. If you are a beginner, please also consider additional books or tutorials.

Introduction

New GRASS development has made major improvements to the vector architecture. The most significant change includes a new 2- and 3-dimensional vector library that manages vector attributes in standard database management systems (DBMS). This system provides the power of true relational databases for vector attribute management while preserving the flexibility of traditional GRASS topological tools. GRASS now also incorporates true 3-dimensional voxels in the [[1][NVIS]] visualization environment as well as [[2][numerous enhancements]] to virtually every tool in the GRASS library.

Getting started in general

Getting started - how to migrate to the new GRASS version

Raster data management

  • The raster management works as it did in previous GRASS versions.

Vector data management

Grass Six Tutorial Default Settings

      -  Default settings for vector geometry;
         for vector attributes; for db.* modules 

Grass Six Tutorial Geometry Management

       -  General notes on Geometry 
         management; Managing the default settings; 
         GRASS vector architecture; Geometry stored in native format;
         Geometry stored in SHAPE file; 
         Import/export of vector data Geometry;
         Generating vector geometry from various sources

Grass Six Tutorial Attribute Management

       - General notes on Attribute 
         management; Managing the default settings; Examples;
         Database Schema

Usage examples

Basic usage examples

Complex usage examples

Vector network analysis examples

Vector overlay/clipping examples

Examples from US National Atlas

FAQ (Frequently Asked Questions)

  • Grass Six Tutorial Faq

Troubleshooting

  • Grass Six Tutorial Troubleshooting

Links of interest

Further reading

GRASS and R kriging interpolation

Mini How to interpolate using kriging with GRASS and R

            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 R from the GRASS prompt, and type:

library(spgrass6) 

#get vector points as SpatialPointsDataFrame 
giaciture <- getSites6sp("giaciture_cat_clean3") 

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...

#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)"
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 SpatialGridDataFrame
mask_SG <- SpatialGridDataFrame(grd
                                ,data=list(k=rep(1,G$cols*G$rows))
                                ,proj4string=CRS(G$proj4)) 

class(mask_SG)

library(gstat)

cvgm <- variogram(IMMERSIONE~1,locations=giaciture,width=400,cutoff=4000)
#create variogram, and "IMMERSIONE" 
#here is the our variable, the variable on wich we have to do the prediction,
# ~ 1 select the type of kriging, this is the ordinary one

efitted <- fit.variogram(cvgm,vgm(psill=5000,model="Exp",range=1500,nugget=8000))
# choose the model to fit variogram (here is exponential) and give the
# estimated parameters of the variogram (partial sill, range and nugget)

OK_pred <- krige(IMMERSIONE~1,locations=giaciture,newdata=mask_SG,model=efitted)
# make the kriging prediction

names(OK_pred) #show the name of variable kriged

writeRast6sp(OK_pred,"OK_pred",zcol="var1.pred",NODATA=-9999) 
#write a raster file and save it in GRASS, now you can open it from there.

that's all!

special thanks to Roger Bivand, ever ready to lend a hand!

Category Tutorial