/*! \page pythonlib GRASS Python scripting library
by GRASS Development Team (http://grass.osgeo.org)
\section intro Introduction
The code in lib/python/ provides grass.script in order
to support GRASS scripts written in Python. The scripts/
directory of GRASS contains a series of examples actually provided to
the end users.
See code in:
- core.py
- db.py
- raster.py
- vector.py
Table of content
- \subpage scripting
- \subpage modules
- \subpage core
- \subpage db
- \subpage raster
- \subpage vector
\section scripting GRASS scripting tasks for Python provided by "grass.script"
Usage:
\code
from grass.script import core[,db[,raster,[vector]]] as grass
\endcode
e.g. to import functions from "core" and "vector" modules use
\code
from grass.script import core, vector as grass
\endcode
Sample script
\code
#!/usr/bin/env python
#%Module
#% description: Checks if vector map is 3D
#% keywords: vector
#%End
#%option
#% key: map
#% type: string
#% gisprompt: old,vector,vector
#% key_desc: name
#% description: Name of vector map
#% required: yes
#%end
import sys
from grass.script import core as grass
def main():
info = grass.parse_command('v.info',
flags = 't',
map = options['map'])
if info['map3d'] == '1':
print 'Vector map is 3D'
else:
print 'Vector map is 2D'
return 0
if __name__ == "__main__":
options, flags = grass.parser()
sys.exit(main())
\endcode
\section modules List of modules
\subsection core Core
GRASS-oriented interface to subprocess module
- exec_command()
- feed_command()
- make_command()
- parse_command()
- pipe_command()
- read_command()
- run_command()
- start_command()
- write_command()
Interface to g.message
These all run g.message, differing only in which flag (if any) is
used. fatal() is error(), but also calls sys.exit(1).
- debug()
- error()
- fatal()
- info()
- message()
- verbose()
- warning()
Interface to g.parser
Interface to g.parser, intended to be run from the top-level, e.g.
\code
if __name__ == "__main__":
options, flags = grass.parser()
main()
\endcode
- parser()
Interface to g.tempfile
Returns the name of a temporary file, created with g.tempfile.
- tempfile()
Key-value parsers
- parse_key_val()
Interface to g.gisenv
- gisenv()
Interface to g.region
- del_temp_region()
- region()
- use_temp_region()
Interface to g.findfile
- find_file()
Interface to g.list
- list_grouped()
- list_pairs()
- list_strings()
- mlist_grouped()
Color parsing
- parse_color()
Check GRASS environment variables
- overwrite()
- verbosity()
Various utilities, not specific to GRASS
- basename()
- find_program()
- try_remove()
- try_rmdir()
- float_or_dms()
\section db Database
Interface for db.* modules.
\code
from grass.script import db as grass
\endcode
- db_connection()
- db_describe()
\section raster Raster
Interface for r.* modules.
\code
from grass.script import raster as grass
\endcode
- raster_history()
- raster_info()
- mapcalc()
\section vector Vector
Interface for v.* modules.
\code
from grass.script import vector as grass
\endcode
- vector_columns()
- vector_db()
- vector_history()
- vector_info_topo()
- vector_layer_db()
*/