Difference between revisions of "GRASS 6 Tutorial"

From GRASS-Wiki
Jump to: navigation, search
 
m (Examples from US National Atlas [from GRASS 5.7 tutorial])
 
(108 intermediate revisions by 11 users not shown)
Line 1: Line 1:
The Free Software/Open Source GIS GRASS 6 is fully operational and stable version for production use.  This tutorial tries to
+
GRASS GIS version 6.4 is fully operational and stable version that can be used for production use.  This tutorial will familiarize you with the improved functionality and will focus on raster and vector data management as well some basic spatial data analysis.
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.
+
This tutorial is intended for GRASS GIS users who want to migrate from a previous release to the new GRASS Version. If you are a beginner, please also consider additional [http://grass.itc.it/gdp/tutorials.php books or tutorials] as well as consulting the [[GRASS_Help| Introductory Material]].  
 +
 
  
 
'''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!
 
'''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,
+
'''''NOTE: This tutorial is under construction and is incorporating sections of the [http://grass.osgeo.org/grass57/tutorial/ previous GRASS 5.7 tutorial].'''''
please also consider additional [http://grass.itc.it/gdp/tutorials.php books or tutorials].
 
  
 
==Introduction==
 
==Introduction==
  
New GRASS development has made major improvements to the vector
+
New developments in GRASS GIS have made major improvements to the vector
 
architecture. The most significant change includes a new 2- and
 
architecture. The most significant change includes a new 2- and
 
3-dimensional vector library that manages vector attributes in
 
3-dimensional vector library that manages vector attributes in
standard database management systems (DBMS). This system provides the
+
standard database management systems (DBMS), providing a fully relational database for vector attribute management,
power of true relational databases for vector attribute management
 
 
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 NVIZ] 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.
  
==Getting started in general==
+
If you are new to GRASS GIS and plan to use the command line inteface and/or within a Linux environment, it is recommended that you read the [http://www.linux.org/lessons/ Introductory Material] for Linux. Also, if you have been using other GIS packages, you may find the [[GRASS_Help#Migration_from_other_GIS_Software|Migration tips]] useful reading.
  
* [[Introductional Material]] to Linux and GRASS
+
This tutorial is designed to give you hands-on experience with GRASS GIS. We start by showing you how to view and query raster and vector data and continue by explaining how to import and process raster and vector data.
 
+
==Getting started - how to migrate to the new GRASS version==
+
===[http://grasswiki.osgeo.org/wiki/GRASS_6_Tutorial/Getting_Started Getting started]===
  
* [[Grass Six Tutorial Getting Started]]
+
===[http://grasswiki.osgeo.org/wiki/GRASS_6_Tutorial/Displaying_spatial_data Displaying Spatial Data]===
  
==Raster data management==
+
==Using GRASS with raster data==
  
* The raster management works as it did in previous GRASS versions.
+
===Overview===
  
==Vector data management==
+
This section of the tutorial is intended to provide new users with an introduction to raster data management in GRASS GIS. As with other parts of the GRASS 6 tutorial, the examples are largely based on the GRASS 5.7 tutorial as well as the GRASS GIS presentation at Geostat-2012. The aim is to present the reader with introductory information on handling raster data within GRASS GIS. It is worth mentioning that the raster management hasn't changed significantly from previous versions of GRASS (e.g. versions 4 or 5), therefore older tutorials and books on the GRASS raster modules should also work.
  
===[[Grass Six Tutorial Default Settings]]===  
+
===[http://grasswiki.osgeo.org/wiki/GRASS_6_Tutorial/Raster_data_management Raster Data Management]===
      -  Default settings for vector geometry;
 
          for vector attributes; for db.* modules
 
  
===[[Grass Six Tutorial Geometry Management]]===
+
==Using GRASS with vector data==
        -  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]]===
+
===Overview===
        - General notes on Attribute
+
The native GRASS vector format provides provides vector topology with n:m mapping of geometry features to attributes. In addition, vector layers are supported with a variety of database management systems (DBMS) supported as back-ends that include: SQLite, PostgreSQL + PostGIS, MySQL, ODBC (, DBF). The vector geometry types supported in GRASS includes: points, centroids, lines, boundaries, areas (boundaries + centroids), face (3d areas), kernels and volumes.
          management; Managing the default settings; Examples;
 
          Database Schema
 
  
==Usage examples==
+
The examples that follow in this section on vector data management are based on the datasets available [http://data.neteler.org/geostat2012/north_carolina here]
 
 
===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
+
===[http://grasswiki.osgeo.org/wiki/GRASS_6_Tutorial/Vector_data_management Vector Data Management]===
  
==Troubleshooting==
+
===[http://grasswiki.osgeo.org/wiki/GRASS_6_Tutorial/Vector_spatial_analysis Vector Spatial Analysis]===
  
* Grass Six Tutorial Troubleshooting
+
===Vector network analysis examples [from GRASS 5.7 tutorial]===
  
==Links of interest==
+
* New Spearfish examples: [http://grass.osgeo.org/grass63/manuals/html63_user/v.net.html v.net], [http://grass.osgeo.org/grass63/manuals/html63_user/v.net.iso.html v.net.iso], [http://grass.osgeo.org/grass63/manuals/html63_user/v.net.path.html v.net.path] etc.
 +
* Old tutorial: http://grass.osgeo.org/grass57/tutorial/network.html
 +
<!--- dmci: This is commented out as it has been updated in vector data management, tho' useful for reference to go back to check that everything has been incorporated.
 +
===Basic usage examples  [from GRASS 5.7 tutorial]===
 +
http://grass.osgeo.org/grass57/tutorial/ex_basic.html
 +
--->
 +
===[http://grass.osgeo.org/grass57/tutorial/ex_complex.html Complex usage examples  [from GRASS 5.7 tutorial]]===
  
* GRASS-GMT Examples: http://169.237.35.250/~dylan/grass_user_group/
+
===[http://grass.osgeo.org/grass57/tutorial/usa_demo.html Examples from US National Atlas  [from GRASS 5.7 tutorial]]===
  
==Further reading==
+
==Using GRASS with R==
  
 
===GRASS and R kriging interpolation===
 
===GRASS and R kriging interpolation===
  
====Mini How to interpolate using kriging with GRASS and R====
+
===Mini How to interpolate using kriging with GRASS and R===
  
            ORDINARY KRIGING IN R WITH GRASS6 DATA
+
[[How to interpolate point value using kriging method with R and GRASS 6]]
  
Of all the methods we tried this is the most easy and (I suppose) exact too:
+
==Using GRASS with GMT==
  
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".
+
* [http://169.237.35.250/~dylan/grass_user_group/ GRASS-GMT Examples]
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:
+
==Additional Information==
  
<pre>
+
===FAQ (Frequently Asked Questions)===
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
 
</pre>
 
 
 
now if you want you can continue to work in R from GRASS or not...
 
 
 
<pre>
 
#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)
+
* [[Faq|GRASS Wiki FAQ]]
# make the kriging prediction
 
  
names(OK_pred) #show the name of variable kriged
+
* [[Grass Six Tutorial Faq]]
  
writeRast6sp(OK_pred,"OK_pred",zcol="var1.pred",NODATA=-9999)
+
* [http://grasswiki.osgeo.org/wiki/GRASS_Help Help and Troubleshooting]
#write a raster file and save it in GRASS, now you can open it from there.
 
</pre>
 
  
that's all!
+
=== References ===
  
special thanks to Roger Bivand, ever ready to lend a hand!
+
* GRASS [http://grass.osgeo.org/gdp/tutorials.php books and tutorials]
 +
<!--- dmci: link not working * GRASS 6 Tutorial at [http://www.gdf-hannover.de/literature GDF]
 +
* Translation Portal for GRASS 6 Tutorial http://www.gdf-hannover.de/translation--->
 +
* GRASS [http://www.geostat-course.org/Topic_NetelerMetz_2012 GEOSTAT 2012] course
  
* GRASS <a href="http://grass.itc.it/gdp/tutorials.php">books and tutorials</a>
 
* GRASS 6 Tutorial: http://www.gdf-hannover.de/literature
 
* Translation Portal for GRASS 6 Tutorial http://www.gdf-hannover.de/translation
 
  
==Category Tutorial==
+
[[Category: Documentation]]
 +
[[Category: Tutorial]]

Latest revision as of 01:29, 30 July 2013

GRASS GIS version 6.4 is fully operational and stable version that can be used for production use. This tutorial will familiarize you with the improved functionality and will focus on raster and vector data management as well some basic spatial data analysis.

This tutorial is intended for GRASS GIS 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 as well as consulting the Introductory Material.


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!

NOTE: This tutorial is under construction and is incorporating sections of the previous GRASS 5.7 tutorial.

Introduction

New developments in GRASS GIS have 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), providing a fully relational database for vector attribute management, while preserving the flexibility of traditional GRASS topological tools. GRASS now also incorporates true 3-dimensional voxels in the NVIZ visualization environment as well as numerous enhancements to virtually every tool in the GRASS library.

If you are new to GRASS GIS and plan to use the command line inteface and/or within a Linux environment, it is recommended that you read the Introductory Material for Linux. Also, if you have been using other GIS packages, you may find the Migration tips useful reading.

This tutorial is designed to give you hands-on experience with GRASS GIS. We start by showing you how to view and query raster and vector data and continue by explaining how to import and process raster and vector data.

Getting started

Displaying Spatial Data

Using GRASS with raster data

Overview

This section of the tutorial is intended to provide new users with an introduction to raster data management in GRASS GIS. As with other parts of the GRASS 6 tutorial, the examples are largely based on the GRASS 5.7 tutorial as well as the GRASS GIS presentation at Geostat-2012. The aim is to present the reader with introductory information on handling raster data within GRASS GIS. It is worth mentioning that the raster management hasn't changed significantly from previous versions of GRASS (e.g. versions 4 or 5), therefore older tutorials and books on the GRASS raster modules should also work.

Raster Data Management

Using GRASS with vector data

Overview

The native GRASS vector format provides provides vector topology with n:m mapping of geometry features to attributes. In addition, vector layers are supported with a variety of database management systems (DBMS) supported as back-ends that include: SQLite, PostgreSQL + PostGIS, MySQL, ODBC (, DBF). The vector geometry types supported in GRASS includes: points, centroids, lines, boundaries, areas (boundaries + centroids), face (3d areas), kernels and volumes.

The examples that follow in this section on vector data management are based on the datasets available here

Vector Data Management

Vector Spatial Analysis

Vector network analysis examples [from GRASS 5.7 tutorial]

Complex usage examples [from GRASS 5.7 tutorial]

Examples from US National Atlas [from GRASS 5.7 tutorial]

Using GRASS with R

GRASS and R kriging interpolation

Mini How to interpolate using kriging with GRASS and R

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

Using GRASS with GMT

Additional Information

FAQ (Frequently Asked Questions)

References