Introduction to
GRASS GIS

Helena Mitasova
and Vaclav Petras

GIS/MEA582 Geospatial Modeling and Analysis NCSU

Learning Objectives

This lecture is a brief introduction to GRASS GIS software and overview of its features in the context of this course and open source software in general.

Open Source and Licensing

  • According to Stallman (2002), there are four freedoms that as a user you should have:
    • the freedom to use the software for any purpose,
    • the freedom to change the software to suit your needs,
    • the freedom to share the software, and
    • the freedom to share the changes you make.
Logo of GNU GPL license, version 3

Stallman, R. M. (2002). Free software, free society: selected essays. Ed. by J. Gay. 1st. ed. OCLC: 253840339. Boston, Mass: Free Software Foundation. 220 pp. ISBN 978-1-882114-98-6.

Free, Libre, and Open Source

  • free software (FS), open source software (OSS), free and open source software (FOSS), free, libre and open source software (FLOSS)
  • the term open source is often used for simplicity
    • often used by developers as it refers to a development model
  • the term FOSS is often used in geospatial community
    • free refers to user's freedom
    • open source refers to open development model
    • FOSS4G (free and open source software for geospatial)

Commercial and FOSS

  • FOSS can be used commercially
  • FOSS can be commercial but not proprietary
  • FOSS can be used to build closed platforms
  • Famous FOSS examples (non-geospatial):
    • Red Hat Enterprise Linux/CentOS
    • Android/Android Open Source Project
    • Chrome/Chromium, Firefox
    • WordPress, Drupal
    • Moodle
    • Python, R
    • Apple, Google, Facebook, Amazon, Netflix

FOSS Ecosystem: Example of a Scientific Desktop Setup

QGIS, GRASS GIS
GIS, remote sensing, cartography
R, Octave, Python
statistics, linear algebra, scripting, automation
SQLite, PostgreSQL with PostGIS, LibreOffice
database, tabular data
Inkscape, Gimp, ImageMagic
vector graphics, raster graphics
  • Portability: works on Mac, Linux, Windows
  • Interoperability: programs designed to work with others

FOSS Ecosystem: Example of a Service Setup

GRASS GIS, R, SAGA GIS, GDAL
backend processing
OpenLayers or Leaflet, Django or Flask
front end
PostgreSQL with PostGIS
database (spatial and non-spatial data storage)
ZOO-Project, PyWPS, GeoServer, or QGIS Server
processing server and spatial data publishing server
  • Flexibility: standards and open formats allows to switch different components
  • Scalability: can be copied to more machines at no cost

GRASS GIS

GRASS GIS (Geographic Resources Analysis Support System) is a Free and Open Source Software suite for geospatial data management and analysis, image processing, spatial modeling, and visualization.

grass.osgeo.org

Source code in github

GRASS GIS

  • Timeline:
    • 1983 started at US Army CERL as land management system
    • evolved into general purpose GIS
    • 1999 GNU GPL, international team of developers
    • 2008 OSGeo Project
    • 40+ years of GRASS GIS development

Historical Video

Historical promotional video from 1987 narrated by William Shatner

watching 1 minute is sufficient to get the idea, optionally you can watch the whole 15 minutes and see metadata and transcript at doi.org/10.5446/12963

Processing Capabilities Overview

raster and 3D raster
map algebra, DEM, interpolation, flow, neighborhood, solar, cost surfaces, ...
imagery (remote sensing)
rectification, multispectral, classification, segmentation, PCA, FFT, ML, ...
vector and database
buffers, overlays, networks, topology, attribute management, SQL, ...
spatio-temporal data (time series)
sampling, statistics, aggregation, temporal topology, algebra, ...

General Capabilities Overview

visualization
2D display, 3D visualization, temporal visualization, PNG, PS and PDF maps, ...
interoperability
import from and export to different formats, WMS, ...
extensibility
scriptable (e.g. Python), custom tools (typically Python or C), ...

Visualization of a planned drone flight over digital surface model with ortho

Research Use


Example application: summer solstice solar radiation dynamics on lidar DEM (Centennial Campus)

Software Description

  • portable:
    • many operating systems: MS Windows, Mac OS, Linux, ...
    • high-end desktops, low-end laptops, Raspberry Pi, High-Performance Computing clusters, ...
  • single integrated software
  • functionality implemented as 500+ modules
  • written in C and Python

Naming Convention for Modules

Prefix Functionality Example
r. raster processing r.mapcalc: raster map algebra
v. vector processing v.surf.rst: interpolation from pointsi to raster
g. general management g.remove: removes maps
d. display and rendering d.rast: display raster map
i. imagery processing i.segment: image segmentation
r3. 3D raster processing r3.stats: 3D raster statistics
t. temporal data processing t.rast.aggregate: temporal aggregation

User Interfaces

  • Modules can be accessed using:
    • Graphical User Interface (GUI)
    • Command Line Interface (CLI)
    • Python

Graphical User Interface

  • The interface for desktop

GUI for GRASS GIS 7, redesign coming with GRASS GIS 8.3

GUI for modules

  • All modules have standardized, unified interface layout.

Standard dialog (form) for the r.neighbors module

Command Line

  • The baseline interface for efficiency and reproducibility
  • Available in GUI as Console with autocomplete functions
r.fill.dir input=elev output=fill direction=dir

Python

  • grass package part of GRASS GIS
  • access to modules, but also to internal C functions
  • integrated Python editor
  • integrates with Jupyter Notebooks
import grass.script as gs
gs.run_command('r.fill.dir', input='elev',
               output='fill', direction='dir')

Duality between GUI and commands

Command line (Bash):
Python:

Examples in the documentation and class instructions are usually provided as commands which can be used to fill in the GUI, write Python code, or run them directly.

3rd Party Interfaces

  • QGIS (Processing Plugin and GRASS Plugin)
  • R (rgrass package)
  • ...

3rd Party Interfaces

  • Tangible Landscape
    • tangible user interface to GRASS GIS and Blender
    • by NC State University, Center for Geospatial Analytics

Modules running: v.surf.rst, r.contour, r.fill.dir, r.sim.water
see also Petrasova et al., 2018, Tangible Modeling with Open Source GIS, 2nd edition, Springer

Documentation: Users manual

Each module has a standardized manual page

Public Author & Accessible Code

Link to Research Papers

Addons Repository

  • 300+ user contributed modules and tools
  • integrated with g.extension
  • including compiled C and C++ for MS Windows
  • automatically generated GUI for Python and C/C++

Spatial Database

Example of GRASS GIS database structure into locations (based on SRS) and further to mapsets (for organization)

Spatial Database

Spatial Database and Locations

Database, Locations, and Mapsets

Database, Locations, Mapsets, Maps

Starting GRASS GIS 7

  • Selecting database, location, and mapset

grass -c EPSG:3358 -e ~/grassdata/nc_spm/

GRASS GIS start-up is redesigned for GRASS GIS 8.3

Computational Region

  • extent and resolution for raster computations

Try GRASS GIS with Jupyter Notebooks

GRASS GIS workshops and tutorials implemented as Jupyter Notebooks in Binder:

Summary

  • Licensing: No "purchasing of licenses" needed for users
  • Support: Community and commercial
    • Students: Start with course message board now; try mailing list or GIS StackExchange later on
  • Several user interfaces
    • Class instructions are using GUI and command line
    • Python and Jupyter are recommended for the projects
  • Data in database, locations and mapsets
  • Raster operations in a specified computational region