An Introduction to GRASS GIS

A case study with North Carolina data


This demo will introduce you to some of the basics of a working Geographic Information System using GRASS, a fully functioning and open-source GIS. For this demo, you will need to download a sample data set to one of the CS Linux lab machines. This data set is 14MB zipped and uncompresses to about 23MB. If you do not have room on your home directory, you can save the files on /local/.

NC Sample Dataset

For this demo, I'll assume you have extracted the data in /local/. You may need to change the paths accordingly if you put the data somehere else.

Starting GRASS

Currently, grass 6.2 is installed on all the lab machines. To get started, type grass62 -text at the command line. You'll be presented with a screen that asks for a LOCATION, MAPSET, and DATABASE. For LOCATION, enter NCdemo. For MAPSET, enter your login name. This will create a subdirectory under /local/NCdemo where files you create will be stored. For DATABASE, enter /local/ or the path where you extracted the NCdemo data. Then type <ESC>-<ENTER> to start using the data in this LOCATION.

Viewing Data

Here is the quickest way to see something. Type d.mon x0 to bring up a display window. Then type d.vect counties_nc type=boundary color=black to view the county boundaries of the state of North Carolina. Next type g.region rast=neuse500 followed by d.erase; d.rast neuse500 to view an elevation map of the Neuse river basin. You can type d.vect counties_nc type=boundary color=black again (or hit the up arrow a few times to display the commands from your history) to overlay the counties, but now only the counties in the region of the Neuse river basin are displayed.

Grass commands begin with g., d., r., or v. to indicate the command is a general command, display command, raster command, or vector command, respectively. Each grass command is a UNIX executable, and the GRASS terminal is just like a standard shell with TAB-completion, so if you hit g.<TAB> you can see the list of all g. commands. Almost any command will give you usage instructions if you specify the -h flag, for example d.erase -h. Let's look at a few more g. and d. commands.

The g.list command shows you what raster or vector layers you have in your current location. Try typing g.list rast and g.list vect. You should see the names of files you displayed earlier. Each layer has it's own spatial extent. The county layer covers the whole state while the neuse500 layer only covers the Neuse river basin. The viewing window you created using d.mon x0 also has a separate spatial extent. You can change it by running d.zoom to zoom in and out. If you ever get lost while zooming, you can set the display window extent (also called a region) to the region of a known layer. So g.region rast=neuse500 will reset the region to the boundaries of the neuse500 data set.

Quitting GRASS

Type exit. GRASS should clean up any open windows and return you to a shell.

Using the GUI

GRASS also has a GUI mode that you can set to be the default by typing grass62 -gui at the command line. Afterwards if you just type grass62, you'll be sent to the GUI menus. You can still use the terminal to enter commands. If you start in text mode and want the GUI, you can type gis.m at the command prompt. The GUI is pretty new to me, so I prefer the old command line approach. You are welcome to try out the GUI, but I can't answer too many questions about it.