Luis Lisboa wrote:

> I'm programming a few Scripts and I would like to know How can I access some
> global variables value such as GRASS_DIR, MAPSET; LOCATIOn or even others
> that I defined (e.g. GRASS_TEMP). How can I load and access them? (I'm
> working with Python scripts for GRASS 7)

Environment variables can be accessed using e.g.:

        gisbase = os.environ["GISBASE"]
or:
        gisbase = os.getenv("GISBASE")

The main difference between the two is that the former raises an
exception if the variable doesn't exist while the latter returns None
(or a user-defined value specified by the second argument).

$GISRC variables (GISDBASE, LOCATION_NAME, MAPSET) can be accessed via
grass.script.gisenv(), e.g.

        import grass.script as grass
        env = grass.gisenv()
        mapset = env["MAPSET"]

-- 
Glynn Clements <[email protected]>
_______________________________________________
grass-dev mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/grass-dev

Reply via email to