[GRASS-user] Getting Started with GRASS Python Scripts

Nikos Alexandris nik at nikosalexandris.net
Thu May 23 17:27:36 PDT 2013

Martin Lacayo wrote:

> I am having trouble getting started with GRASS Python scripts.

Note the following useful GRASS-Wiki pages:

- <http://grasswiki.osgeo.org/wiki/GRASS_and_Python>
- <http://grasswiki.osgeo.org/wiki/GRASS_Python_Scripting_Library>

> I am using GRASS 6.4 on Debian. Could some provide a basic example of a
> Python script that imports a raster and exports the same raster?

You mean importing in the GRASS GIS data base?  Like, you have created a 
Location (no matter which way) and you want to use on of the r.in.* modules to 
import data in a specific Location?

Or is it to load raster maps, already in a GRASS Location, into Python for 
further processing?

> In particular I am interested in seeing the entire setup of a database
> (locally on disk), location, and mapset from start to finish.

> Every example I have found starts with an existing database, location, and
> mapset. I have been able to get past this part by using the GUI, but I
> need to be able to script their creation.

This section in GRASS-Wiki might be of your interest: 

Also, check this source: 

> Is it possible to script the creation of a database (locally on disk),
> location, and mapset?

So, yes it is.

Best, Nikos

More information about the grass-user mailing list