Subsections

3 Sample session: First steps


1 Starting GRASS

Depending on the local installation you can launch GRASS 6 from either the menu or from a terminal window entering:

     grass60

Figure 7: GRASS 6 startup screen with selection of database, location and mapset
\includegraphics[width=0.75\textwidth]{finalpix/grass6_startup_explanations.eps}

A graphical user interface should open as shown in figure 7.

The path to the Database has to be entered into the first field. If you don't have any existing databases, create a new directory (e.g., grassdata/) in your home directory. For the workshop a database will be prepared and indicated. After entering the database you can either use an existing Location (here we use ``spearfish60'') or you can create a new location. We select ``spearfish60'' and create a new Mapset within the Spearfish location, by entering a new name (e.g., your login name) at the right of the startup screen and then clicking the ``Create'' button. The name of the new mapset will appear in the middle column; select it and then enter GRASS by clicking ``Enter GRASS'' at bottom left.

Some explanations:

2 Starting the d.m GIS manager: loading raster and vector maps, map display

Figure 8: GIS manager: loading a raster map
\includegraphics[width=\textwidth]{finalpix/gis_manager_rasterload.eps}
Figure 9: GIS manager: loading a vector map
\includegraphics[width=\textwidth]{finalpix/gis_manager_vectorload.eps}

The built-in GIS manager should open automatically. If not, start it with:

     d.m &

The additional ``SPMamp;'' character launches the command in background, so that you can continue to enter commands into the terminal window. Now load the raster map elevation.dem and the vector map roads as indicated in figures 8 and 9. In general you will select the map type (raster or vector), then select a map from the list, then display the map. There are options to control the map details.

Maps are displayed in a graphical map window which is called the ``GRASS monitor''. You can open several monitors, they are named ``x0'' ... ``x6''. A special monitor is the ``PNG'' driver which sends the contents of the monitor to a PNG file instead of displaying the maps on the screen.

3 Saving the GIS manager settings

When you need to interrupt your work, you should first save all GIS manager settings so that you can pick up where you left off later. This is easily done bygoing to File -> Workspace -> Save as. The settings are saved as a .dm (display manager) file. This file can be reloaded into the GIS manager at a later time.

4 Saving current region settings

Since we work in a GIS, we may want to save not only maps, but also spatial settings. To make a (zoomed) region easily accessible, we can save the current spatial extent and raster resolution. For example, we can zoom into the previously displayed roads and elevation.dem map by either using the GIS manager or by typing d.zoom at the command line (d.z<tab> should do in a bash shell). The different mouse buttons perform different operations:

     Buttons:

          Left: 1. corner (reset)

          Middle: 2. corner

          Right: Quit

If you have only a two-button mouse, the left and right button pressed together emulate the middle button.

Click the left button in the map to zoom. It defines the first corner of the box. You can click the left button as often as you like to find the proper first corner point for the zoom box. Then move the mouse some distance and click the middle button to define the opposite corner of the zoom box. This will zoom the displayed map(s) to the selected area. Now you can either continue like this, or exit zoom mode by clicking the right mouse button. To pan, use d.zoom -p instead, the menu will change slightly.

To save a currently zoomed area as a predefined region, enter:

     g.region save=roadmap

Now we want to reset the Spearfish location to its standard settings, redraw the maps and then zoom into the previously saved subregion:

     g.region -dp

     d.redraw

     g.region region=roadmap

     d.redraw

The monitor should display the zoomed region again.

Note that the QGIS browser comes with an intuitive zoom tool (so we don't have to explain it here).

5 NVIZ visualization tool

Figure 10: NVIZ visualization tool with Spearfish raster and vector maps
\includegraphics[width=0.75\textwidth]{finalpix/nviz_spearfish.eps}

The NVIZ visualization tool is a powerful tool for graphical exploration of raster and vector maps and raster volumes (see figure 10). It permits draping maps over elevation models, stacking several maps, generation of profiles and creation of map fly-throughs. To try it out, we launch it from the command line (you can also use the GIS manager):

     nviz elev=elevation.dem vect=roads

The navigation menu should be rather intuitive. The latest NVIZ software supports different view modes; some of them are similar to a flight simulator perspective.

6 Online help: Help button and g.manual

How to do this and that, you ask? Sure, often we just want to look up the parameter syntax or special hints for a command. Help can be found at different levels:

7 Using the command line

... you have already used it: Using GRASS on the command line means entering a command with its flags and parameters. Using shell commands, powerful scripts can be created. You may remember the file/command name completion which was mentioned earlier. It greatly enhances the speed of constructing commands! Additionally you can scroll up/down to re-use previous commands. Here some important commands:

Alternate graphical user interface: QGIS

So far we have seen ``pure'' GRASS. But there is more to explore: Quantum GIS (QGIS). This is a stand-alone geodata browser with increasing GIS functionality. It is well interfaced now with GRASS. To launch it, just enter within (or without) a GRASS session:

     qgis

Figure 11: QGIS geodata viewer with GRASS interface: Spearfish data
\includegraphics[width=0.75\textwidth]{finalpix/qgis07_spearfish.eps}

8 QGIS: Viewing GRASS maps, adding legends, labels and more

Now we will load some GRASS maps into QGIS. We load the vector maps ``roads'' and ``fields'' and the raster map ``elevation.dem''. Try to replicate the view as shown in the figure 11. If you additionally load the ``aspect'' raster map, you can use the transparency slider to visually merge the elevation model with shades from the aspect map to generate a shaded elevation map. The slider is found when clicking with the right mouse button into the legend. Here you can also define vector legends, labels and more. The stacking order in the legend defines how the maps are displayed.

9 QGIS: Viewing external vector and raster GIS maps (SHAPE, GeoTIFF etc)

Since QGIS is a stand-alone GIS viewer, we can also load external GIS maps such as SHAPE files, GeoTIFF or ERDAS/Img files. They smoothly integrate with the GRASS data if the projections match. From QGIS 0.7 onwards vector reprojection on the fly will be supported, simplifying again the integration of heterogeneous data sources.

Add some TIGER 2000 SHAPE maps and LANDSAT-7 GeoTIFF maps to your QGIS view. These files are available for the workshop, they are already reprojected from the original projections to UTM13/NAD27.

10 QGIS: Viewing PostGIS maps

If QGIS was installed with PostGIS support, we can directly load maps from a PostGIS database using the Add PostGIS layer button. PostGIS is a spatial extension for PostgreSQL to store spatial (vector) objects.

If PostGIS is available, a connection can be defined with db.connect (see the related manual page) and then an existing GRASS map copied into PostGIS with g.copy.

11 Creating paper maps with QGIS

Figure 12: QGIS: Map composer tool
\includegraphics[width=0.75\textwidth]{finalpix/qgis07_map_composer_zoom.eps}

Clicking the printer button brings you to the map composer tool which permits creation of a map layout for printing. Figure 12 shows the map composer window. Using the Add new map button you can insert the main view into the map composer tool. Also add a title, a vector legend and a scale. Note that the Refresh view button updates the map composer contents from the main view into the composer. This is convenient if you decide to modify the map again before finalizing it. Maps can be printed, exported as EPS, SVG or high resolution PNG files.

12 QGIS: Export to Mapserver mapfile

A special feature of QGIS is the export of a current view into a UMN/Mapserver mapfile. You first construct the view with all vector legends, transparency etc., then from the main menu select: FILE -> Export Mapserver file. It even includes the paths to GRASS maps.

13 Closing the GRASS session

Now we close our quick-tour through GRASS and QGIS. First close the QGIS window, then the GIS manager. Finally, in the command line terminal, enter:

     exit

to leave GRASS. The monitor(s) are closed automatically.


© 2005, GDF Hannover bR - Solutions for spatial data analysis and remote sensing