<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p>thanks for the answers, but this did not work.</p>
<p>Again, here is my code, this time not just the minimum version:</p>
<p>#!/usr/bin/env python<br>
import os<br>
from grass_session import Session<br>
from grass.script import core as gcore<br>
<br>
from grass.pygrass.modules.shortcuts import general as g<br>
from grass.pygrass.modules.shortcuts import raster as r<br>
<br>
home= "/home/jreith/grassdata/nrw"<br>
gisdb= "/home/jreith/grassdata"<br>
loc= "nrw"<br>
maps= "elevation"<br>
epsg= "EPSG:4647"<br>
xyz=
"/home/jreith/geodaten/dgm1_05314000_Bonn_EPSG4647_XYZ/tmp.xyz"<br>
<br>
if not os.path.exists(gisdb):<br>
os.makedirs(gisdb)<br>
<br>
if not os.path.exists(os.path.join(gisdb, loc)):<br>
with Session(gisdb=gisdb, location=loc, create_opts=epsg):<br>
print("Created a new location!")<br>
else:<br>
print("Location already exist!")<br>
<br>
with open(xyz, "r") as t:<br>
print(t.read())<br>
<br>
with Session(gisdb=gisdb, location=loc, mapset="elevation",
create_opts=""):<br>
print("r.in_xyz works:")<br>
r.in_xyz(input=xyz, output="new_file",
flags="s",separator="space")<br>
gisenvironment = gcore.parse_command("g.gisenv", flags="s")<br>
print(gisenvironment)<br>
compregion = gcore.parse_command('r.in_xyz', input=xyz,
flags='s', output="new_file",separator='space')<br>
##################<b><br>
</b></p>
<p><b>This is my output:</b></p>
<p>GRASSBIN: grass74<br>
GISBASE:
/home/jreith/source/grass-7.4.svn/dist.x86_64-pc-linux-gnu<br>
Location already exist!<br>
32360000.00 5610000.00 170.55<br>
32360000.00 5610001.00 170.56<br>
32360000.00 5610002.00 170.58<br>
32360000.00 5610003.00 170.55<br>
32360000.00 5610004.00 170.58<br>
<br>
<br>
<br>
r.in_xyz works:<br>
Range: min max<br>
x: 32360000 32360000<br>
y: 5610000 5610004<br>
z: 170.55 170.58<br>
{u'MAPSET': u"'elevation';", u'GISDBASE':
u"'/home/jreith/grassdata';", u'LOCATION_NAME': u"'nrw';"}<br>
Traceback (most recent call last):<br>
File "grass_scripts/error_script.py", line 33, in <module><br>
compregion = gcore.parse_command('r.in_xyz', input=xyz,
flags='s', output="new_file",separator='space')<br>
File
"/home/jreith/source/grass-7.4.svn/dist.x86_64-pc-linux-gnu/etc/python/grass/script/core.py",
line 516, in parse_command<br>
res = read_command(*args, **kwargs)<br>
File
"/home/jreith/source/grass-7.4.svn/dist.x86_64-pc-linux-gnu/etc/python/grass/script/core.py",
line 471, in read_command<br>
process = pipe_command(*args, **kwargs)<br>
File
"/home/jreith/source/grass-7.4.svn/dist.x86_64-pc-linux-gnu/etc/python/grass/script/core.py",
line 444, in pipe_command<br>
return start_command(*args, **kwargs)<br>
File
"/home/jreith/source/grass-7.4.svn/dist.x86_64-pc-linux-gnu/etc/python/grass/script/core.py",
line 380, in start_command<br>
return Popen(args, **popts)<br>
File
"/home/jreith/source/grass-7.4.svn/dist.x86_64-pc-linux-gnu/etc/python/grass/script/core.py",
line 74, in __init__<br>
subprocess.Popen.__init__(self, args, **kwargs)<br>
File "/usr/lib/python2.7/subprocess.py", line 711, in __init__<br>
errread, errwrite)<br>
File "/usr/lib/python2.7/subprocess.py", line 1343, in
_execute_child<br>
raise child_exception<br>
OSError: [Errno 2] No such file or directory<br>
###########################<br>
<br>
</p>
<p>I used a minimum example for the xyz-file. As you can see, there
is no problem with the location or database. <br>
</p>
<p>r.in_xyz is correct and also works itself. I also can parse the
g.gisenv to a variable and print it. <br>
</p>
<p>The problem is, that I cannot parse r.in_xyz to a new variable. <br>
</p>
<p>Maybe you have some hints for me :)</p>
<p>best regards</p>
<p>Jonathan<br>
</p>
<br>
<div class="moz-cite-prefix">Am 12.02.2018 um 15:35 schrieb Pietro:<br>
</div>
<blockquote type="cite"
cite="mid:CAM_TVRLuPjL9hAxkhYhKbm56-uyimEQs_duSyhvW3zEqFShevg@mail.gmail.com">
<div dir="ltr">
<div>
<div>
<div>
<div>Dear Jonathan,<br>
<br>
</div>
the error is due to grass_session that is not creating the
location if missing.<br>
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.<br>
<br>
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:<br>
<br>
</div>
```python<br>
from __future__ import print_function<br>
import os<br>
from grass_session import Session<br>
from grass.script import core as gcore<br>
<br>
GISDBASE = "/tmp/grassdata"<br>
LOCATION = "nrw"<br>
EPSG = "EPSG:4326"<br>
<br>
<br>
if not os.path.exists(GISDBASE):<br>
os.makedirs(GISDBASE)<br>
<br>
if not os.path.exists(os.path.join(GISDBASE, LOCATION)):<br>
with Session(gisdb=GISDBASE, location=LOCATION,<br>
create_opts=EPSG):<br>
print("Created a new location!")<br>
else:<br>
print("Location already exist!")<br>
<br>
<br>
with Session(gisdb=GISDBASE, location=LOCATION,
mapset="elevation",<br>
create_opts=""):<br>
gcore.run_command("g.gisenv")<br>
```<br>
<br>
</div>
Best regards<br>
<br>
</div>
Pietro</div>
</blockquote>
<br>
</body>
</html>