Introduction to GRASS GIS and Scripting in GRASS using Python

FOSS4G-PH 2016 workshop (April 22, 2016)

MH 210, College of Engineering, University of the Philippines Diliman, Quezon City 1191

Engr. Ben Hur S. Pintor

     [email protected]


GRASS GIS, commonly referred to as GRASS (Geographic Resources Analysis Support System), is a free and open source Geographic Information System (GIS) software suite used for geospatial data management and analysis, image processing, graphics and maps production, spatial modeling, and visualization. GRASS GIS is currently used in academic and commercial settings around the world, as well as by many governmental agencies and environmental consulting companies. It is a founding member of the Open Source Geospatial Foundation (OSGeo).

It is the granddaddy of most open-source and modern-day GIS with its history dating back to its development by the U.S. Army Construction Engineering Research Laboratories (CERL) way back in 1982.



GRASS Installation

Instructions for installation of GRASS in GNU/Linux, MS Windows, and Mac OS are available at:

GRASS Data Structure


The directory where LOCATIONS are stored. Common example is ~/user/grassdata


A LOCATION is some geographic extent of interest that contains data sets that must all be in the same coordinate system. Every location has a PERMANENT directory which stores some basic information about the whole location, and is a good place to park base files. You can think of a location as a data library for a region of interest defined by a coordinate reference system.


Every GRASS session runs under the name of a MAPSET. A MAPSET may be a geographical or thematic subset of the parent LOCATION. Technically they are subdirectories under any location. Users may only select (and thus modify) a mapset that they own (i.e., have created). However, data in all mapsets for a given location can be read by anyone (unless prevented by UNIX file permissions). The "PERMANENT" mapset usually contains the read-only base maps like the elevation model, while the other locations are readable and writable by their owners. The "PERMANENT" mapset also contains some information about the location itself that is not found in other mapsets (projection info etc.), thus it must exist in every location.

Computational Region

The current region or computational region is the actual setting of the region boundaries and the actual raster resolution. As a general rule in GRASS:

GRASS Command Structure

Starting GRASS

GRASS Startup Screen


The first window is the Layer Manager which is Similar to the Table of Contents window of other GIS such as ArcGIS and QGIS. Here you can see the current layers (data) loaded into GRASS session. Adding or removing layers in the Layer Manager can be done using the Layer Manager toolbox

The other window is the Map Display which displays the layers in the Layer Manager.

For more information regarding the GUI, see: GRASS GIS Manual: wxGUI

Aside from the GUI, there are several other ways to search and send commands to GRASS. These are through the:

Command Console

Search Module

Python Shell


Introduction | Raster Processing and Analysis | Vector Processing and Analysis | WORKSHOP 1 | WORKSHOP 2 (Scripting)