Part 1: Intro to GRASS GIS

Basic notions, interfaces and temporal framework

Author

Veronica Andreo

Published

June 2, 2023

GRASS GIS general stuff

  • GRASS GIS (Geographic Resources Analysis Support System), a FOSS suite used for geospatial data management and analysis, image processing, graphics and maps, spatial modeling, and visualization.
  • Originally developed by the U.S. Army Construction Engineering Research Laboratories for land management and environmental planning (1982-1995).
  • First User Manual published on July 29th, 1983… GRASS is becoming 40 this year!
  • More history: https://grass.osgeo.org/about/history/
  • Free and open source, you can use, modify, improve, share
  • Strong user community, commercial support
  • Large amount of tools: 500+ core modules, 400+ addons
  • GUI and CLI interfaces
  • Python API and libraries - the latest grass.jupyter library can be tried online
  • Connection with R, QGIS, WPS, etc.
  • Different data types supported: raster (including satellite imagery), 3D raster or voxel, vector and space-time datasets

Open GRASS for the first time

As of version 8.0, GRASS has modified its startup to make it more user friendly:

From the Data catalog tab you can manage several actions and if you do not yet have imported data into the GRASS database, the software creates the directory structure or database automatically.

Database

  • GRASS database (directory with projects): When running GRASS GIS for the first time, a folder named “grassdata” is automatically created. Depending on the operating system, it can be found in $HOME (*nix) or My Documents (MS Windows).
  • Location (a project): A location is defined by its coordinate reference system (CRS). The location that is automatically created is in WGS84 (EPSG:4326). If you have data in another CRS, you should ideally create a new location.
  • Mapset (a subproject): Each location can have many mapsets to manage different aspects or sub-regions of a project. When creating a new location, GRASS GIS automatically creates a special mapset called PERMANENT where the central data of the project (e.g., base maps, road network, dem, etc.) can be stored.

Computational region

Another fundamental concept of GRASS GIS (and very useful when working with raster data) is that of the computational region. It refers to the boundary configuration of the analysis area and spatial resolution (raster). The computational region can be defined and modified with the command g.region to the extent of a vector map, a raster or manually to some area of interest. The output raster maps will have an extent and spatial resolution equal to the computational region, while vector maps are always processed at their original extent.

Note

For more details, see the wiki on Computational Region.

Modules and extensions

GRASS has more than 500 modules for the most varied tasks:

Prefix Function class Type of command Example
g.* general general data management g.rename: renames map
d.* display graphical output d.rast: display raster map
r.* raster raster processing r.mapcalc: map algebra
v.* vector vector processing v.clean: topological cleaning
i.* imagery imagery processing i.pca: Principal Components Analysis on imagery group
r3.* voxel 3D raster processing r3.stats: voxel statistics
db.* database database management db.select: select value(s) from table
ps.* postscript PostScript map creation ps.map: PostScript map creation
t.* temporal space-time datasets t.rast.aggregate: raster time series aggregation

Extensions or add-ons can be installed from the central GitHub repository or from other users’ GitHub (or similar repositories) using the command g.extension. For example:

 # install an extension from the GRASS GIS repository
 g.extension extension=r.hants
 
 # install an extension from another GitHub repository
 g.extension extension=r.change.stats \
   url=https://github.com/mundialis/r.change.stats

Graphical User Interface (GUI)

Command line

GRASS +

There are different Python libraries delivered with GRASS GIS, we’ll use 2 of them:

  • grass.script which provides Python interface to launch GRASS GIS modules in scripts
  • grass.jupyter which offers classes and setup functions for running GRASS GIS in Jupyter Notebooks

Other Python libraries delivered with GRASS GIS include: pygrass, the temporal framework, the testing framework, among others.

We can use Python within GRASS GUI, within Jupyter notebooks, or from our preferred IDE. See the options within the GUI:

GRASS + through rgrass package

We can use R within a GRASS GIS session or use GRASS GIS within an R session. We’ll explore this further in the last part of this session.

Demo session overview

Habitat suitability mapping for the Asian tiger mosquito in Northern Italy based on variables derived from daily LST data

  • GRASS
    • Import species records
    • Create random background points
    • Create different environmental layers from daily LST data
  • R
    • Read data from GRASS into R
    • Model species distribution
    • Model evaluation
    • Visualization of results

Data for the session

  • Records of Aedes albopictus (Asian tiger mosquito) in Northern Italy downloaded from GBIF
  • Average daily MODIS LST reconstructed by mundialis GmbH & Co. KG based on Metz et al. (2017):
    • 1 km spatial resolution
    • Converted to Celsius degrees

Get the sample location

  • Create a folder named grass_ncsu_2023
  • Within grass_ncsu_2023 create a folder named grassdata
  • Download and unzip eu_laea location with LST mapset and unzip within your grassdata folder
  • Download mosquito data and drop it within grass_ncsu_2023

The grass_ncsu_2023 folder’s tree should look like this:

  grass_ncsu_2023/
  ├── aedes_albopictus.gpkg
  └── grassdata
      └── eu_laea
          ├── italy_LST_daily
          └── PERMANENT

GRASS GIS HELP!!!

References

Metz, M., Andreo, V., and Neteler, M. (2017), “A New Fully Gap-Free Time Series of Land Surface Temperature from MODIS LST Data,” Remote Sensing, 9, 1333. https://doi.org/10.3390/rs9121333.