Using GRASS 6 without starting it (Python)

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Using GRASS 6 without starting it (Python)

Pedro Camargo
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
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-user
Reply | Threaded
Open this post in threaded view
|

Re: Using GRASS 6 without starting it (Python)

Study
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 <[hidden email]> 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
[hidden email]
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
■□■□■□■□■□■□■□■□■


_______________________________________________
grass-user mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-user
Reply | Threaded
Open this post in threaded view
|

Re: Using GRASS 6 without starting it (Python)

Pedro Camargo
Hi Sittichai,

      The location of the database is J:\MY_PROJECT\GRASS

Is that what you wanted to know?

Thanks,

Pedro

On Fri, Mar 6, 2015 at 5:51 PM, sittichai choosumrong <[hidden email]> wrote:
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 <[hidden email]> 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
[hidden email]
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: <a href="tel:%2B66%2055%20962753" value="+6655962753" target="_blank">+66 55 962753
Mobile: <a href="tel:%2B66%2095-635-8102" value="+66956358102" target="_blank">+66 95-635-8102
■□■□■□■□■□■□■□■□■



_______________________________________________
grass-user mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-user
Reply | Threaded
Open this post in threaded view
|

Re: Using GRASS 6 without starting it (Python)

Micha Silver


On 03/07/2015 08:31 AM, Pedro Camargo wrote:
Hi Sittichai,

      The location of the database is J:\MY_PROJECT\GRASS

Is that what you wanted to know?


So you need to set the GISDBASE variable to the above. NOT as you set in your first mail:

gisdbase = os.path.join(os.getenv('APPDATA', 'GRASS6/grassrc6'))


_______________________________________________
grass-user mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-user
Reply | Threaded
Open this post in threaded view
|

Re: Using GRASS 6 without starting it (Python)

Study
Hi Predo



On BE2558/03/07, at 15:39, Micha Silver <[hidden email]> wrote:



On 03/07/2015 08:31 AM, Pedro Camargo wrote:
Hi Sittichai,

      The location of the database is J:\MY_PROJECT\GRASS

Is that what you wanted to know?


So you need to set the GISDBASE variable to the above. NOT as you set in your first mail:

Yes, as Micha said please set the GISDBASE to "J:\MY_PROJECT\GRASS"

Best, 
-- 
■□■□■□■□■□■□■□■□■
Dr. Sittichai Choosumrong (Ph.D)
Lecturer at Faculty of Agriculture, Natural Resources and Environment,
Department of Natural Resources and Environment, 
Geography
99 Moo 9 Tambon Tha Pho, 
Amphoe Muang
Phitsanulok Thailand 65000
Office: <a href="tel:+66%2055%20962753" x-apple-data-detectors="true" x-apple-data-detectors-type="telephone" x-apple-data-detectors-result="3/0">+66 55 962753
Mobile: <a href="tel:+66%2095-635-8102" x-apple-data-detectors="true" x-apple-data-detectors-type="telephone" x-apple-data-detectors-result="3/1">+66 95-635-8102
■□■□■□■□■□■□■□■□■

_______________________________________________
grass-user mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-user
Reply | Threaded
Open this post in threaded view
|

Re: Using GRASS 6 without starting it (Python)

Pedro Camargo
Hi Sittichai and Micha,

 

I just came back from a conference, thus back to this issue.


I tried many configurations for the code, including the following

gisdbase = os.path.join(os.getenv('APPDATA', 'grassdata'))

and

gisdbase = os.path.join('J:/MY_PROJECT/GRASS/')

and

gisdbase='J:\MY_PROJECT\GRASS'

and

gisdbase = os.path.join(os.getenv('APPDATA')+ "/GRASS6/grassrc6")


For all these, the output was the same, and created a file in the temp folder as below.


c:\users\pedro\appdata\local\temp\tmprdjnow
-1073741515

Any other suggestions?

Thanks a lot,

Pedro



On Sat, Mar 7, 2015 at 4:29 AM, Study <[hidden email]> wrote:
Hi Predo



On BE2558/03/07, at 15:39, Micha Silver <[hidden email]> wrote:



On 03/07/2015 08:31 AM, Pedro Camargo wrote:
Hi Sittichai,

      The location of the database is J:\MY_PROJECT\GRASS

Is that what you wanted to know?


So you need to set the GISDBASE variable to the above. NOT as you set in your first mail:

Yes, as Micha said please set the GISDBASE to "J:\MY_PROJECT\GRASS"

Best, 
-- 
■□■□■□■□■□■□■□■□■
Dr. Sittichai Choosumrong (Ph.D)
Lecturer at Faculty of Agriculture, Natural Resources and Environment,
Department of Natural Resources and Environment, 
Geography
99 Moo 9 Tambon Tha Pho, 
Amphoe Muang
Phitsanulok Thailand 65000
Office: <a href="tel:+66%2055%20962753" target="_blank">+66 55 962753
Mobile: <a href="tel:+66%2095-635-8102" target="_blank">+66 95-635-8102
■□■□■□■□■□■□■□■□■


_______________________________________________
grass-user mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-user
Reply | Threaded
Open this post in threaded view
|

Re: Using GRASS 6 without starting it (Python)

Micha Silver


On 03/15/2015 07:26 AM, Pedro Camargo wrote:
Hi Sittichai and Micha,

 

I just came back from a conference, thus back to this issue.


I tried many configurations for the code, including the following

gisdbase = os.path.join(os.getenv('APPDATA', 'grassdata'))

and

gisdbase = os.path.join('J:/MY_PROJECT/GRASS/')


I'm not an expert in python, but I think you need something like:

gisdbase = os.path.join("J:/","MY_PROJECT","GRASS")

Then, of course, run the grass.init function

and

gisdbase='J:\MY_PROJECT\GRASS'

and

gisdbase = os.path.join(os.getenv('APPDATA')+ "/GRASS6/grassrc6")


For all these, the output was the same, and created a file in the temp folder as below.


c:\users\pedro\appdata\local\temp\tmprdjnow
-1073741515

Any other suggestions?

Thanks a lot,

Pedro



On Sat, Mar 7, 2015 at 4:29 AM, Study <[hidden email]> wrote:
Hi Predo



On BE2558/03/07, at 15:39, Micha Silver <[hidden email]> wrote:



On 03/07/2015 08:31 AM, Pedro Camargo wrote:
Hi Sittichai,

      The location of the database is J:\MY_PROJECT\GRASS

Is that what you wanted to know?


So you need to set the GISDBASE variable to the above. NOT as you set in your first mail:

Yes, as Micha said please set the GISDBASE to "J:\MY_PROJECT\GRASS"

Best, 
-- 
■□■□■□■□■□■□■□■□■
Dr. Sittichai Choosumrong (Ph.D)
Lecturer at Faculty of Agriculture, Natural Resources and Environment,
Department of Natural Resources and Environment, 
Geography
99 Moo 9 Tambon Tha Pho, 
Amphoe Muang
Phitsanulok Thailand 65000
Office: <a moz-do-not-send="true" href="tel:+66%2055%20962753" target="_blank">+66 55 962753
Mobile: <a moz-do-not-send="true" href="tel:+66%2095-635-8102" target="_blank">+66 95-635-8102
■□■□■□■□■□■□■□■□■


This mail was received via Mail-SeCure System.


_______________________________________________
grass-user mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-user