Change in rainfall 2001-2016, global tropics

Map: Change in rainfall 2001-2016, global tropics

Run GRASS from Python

Introduction

GRASS GIS is very versatile and powerful Geographic Information System. And it is Open Source. In this post you learn how to call GRASS functions from a python module without actually starting GRASS.

GRASSDATA, location and mapset

One of the defining features of GRASS GIS is how spatial data is organized at three hierarchihcal levels:

  • GRASSDATA,
  • Location,
  • MapSet

GRASSDATA is the root directory under which all GRASS related spatial data is stored. A Location is defined by a projection and a region, and thus each regional dataset you work with must be defined as a Location. As a region can be global, the GRASSDATA Location used for external calls need only define the projection; the region (map extent) will be defined with each external call. All actual data belonging to a Location is related to a MapSet, where the default MapSet is called PERMANENT. While GRASSDATA and Location must exist beforehand when calling GRASS from an external Python module, the MapSet can be created and changed on the fly.

Setting up GRASS for external calls

Before calling GRASS you must setup GRASSDATA and a Location. To use GRASS as part of Karttur’s GeoImagine Framework you must setup a Location for the projection system(s) you use (e.g. modis, ease2n, ease2t etc. This section illustrates how to setup GRASS for using the EASE-grid north (ease2n) projection system.

Start GRASS

Start GRASS and wait for the Welcome window.