[GRASS-user] Using GRASS 6 without starting it (Python)

sittichai choosumrong sittichai.ocu at gmail.com
Fri Mar 6 16:51:14 PST 2015


He Pedro

Please try to specific your GISDBASE location as the code showing below;

import os
import sys

gisbase = os.environ['GISBASE'] = "C:/Program Files/QGIS
Valmiera/apps/grass/grass-6.4.3"
sys.path.append(os.path.join(os.environ['GISBASE'], "etc", "python"))
gisdbase = os.path.join(os.getenv('APPDATA', 'GRASS6/grassrc6'))

location = "AZ"
gisdbase =  "C:/Users/pcamargo/AppData/Roaming/GRASS6/grassrc6"
mapset   = "AZMAP"

import grass.script as grass
import grass.script.setup as gsetup
gsetup.init(gisbase, gisdbase, location, mapset)

Best,
Sittichai

On Fri, Mar 6, 2015 at 11:16 PM, Pedro Camargo <veigacamargo at gmail.com>
wrote:

> Hi,
>        I have been trying to use GRASS without opening it explicitly
> following the instructions from here:
> http://grasswiki.osgeo.org/wiki/Working_with_GRASS_without_starting_it_explicitly#Python:_GRASS_GIS_6
>
>       Since I am on Windows, I had to adapt it a bit (and I tried many,
> many variations).  The most likely
>
>
> import os
> import sys
> location = "AZ"
> mapset   = "AZMAP"
> gisbase = os.environ['GISBASE'] = "C:/Program Files/QGIS
> Valmiera/apps/grass/grass-6.4.3"
> sys.path.append(os.path.join(os.environ['GISBASE'], "etc", "python"))
> gisdbase = os.path.join(os.getenv('APPDATA', 'GRASS6/grassrc6'))
> import grass.script as grass
> import grass.script.setup as gsetup
> gsetup.init(gisbase, gisdbase, location, mapset)
>
>
> What I get when I run these lines is the line below:
>
> 'c:\\users\\pcamargo\\appdata\\local\\temp\\tmp7wvogg'
>
>
> The content of this file is
>
> GISDBASE: C:/Users/pcamargo/AppData/Roaming/GRASS6/grassrc6
> LOCATION_NAME: AZ
> MAPSET: AZMAP
>
> While it should be getting the contents from the file at
> C:\Users\pcamargo\AppData\Roaming\GRASS6\grassrc6
>
>
> What am I doing wrong?
>
> Thanks,
>
> Pedro
>
>
>
> _______________________________________________
> grass-user mailing list
> grass-user at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/grass-user
>



-- 
Dr.Sittichai Choosumrong
-------------------------
Lecturer,
Geography and Geographic Information Science (GISci)
Department of Natural Resources and Environment,
Faculty of Agriculture, Natural Resources and Environment,
Naresuan University, Thailand 65000

Office: +66 55 962753
Mobile: +66 95-635-8102
email: sittichaic at nu.ac.th
■□■□■□■□■□■□■□■□■
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20150307/27317ced/attachment.html>


More information about the grass-user mailing list