[GRASS-user] python parse_command

Pietro peter.zamb at gmail.com
Mon Feb 12 06:35:28 PST 2018


Dear Jonathan,

the error is due to grass_session that is not creating the location if
missing.
I don't have time in this day to fix this issue in grass_session, so the
fastest fsolution at the momenth is to check and create what is needed step
by step.

I did not have xyz file to test so I've only execute g.gisenv and it works,
let me know if it works also with r.inxyz:

```python
from __future__ import print_function
import os
from grass_session import Session
from grass.script import core as gcore

GISDBASE = "/tmp/grassdata"
LOCATION = "nrw"
EPSG = "EPSG:4326"


if not os.path.exists(GISDBASE):
    os.makedirs(GISDBASE)

if not os.path.exists(os.path.join(GISDBASE, LOCATION)):
    with Session(gisdb=GISDBASE, location=LOCATION,
                 create_opts=EPSG):
        print("Created a new location!")
else:
    print("Location already exist!")


with Session(gisdb=GISDBASE, location=LOCATION, mapset="elevation",
             create_opts=""):
    gcore.run_command("g.gisenv")
```

Best regards

Pietro
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20180212/73913c8e/attachment-0001.html>


More information about the grass-user mailing list