[GRASS-user] r.walk output and garray

Dear Grass community,

I am trying to use r.walk from python and the output file seems to be created correctly at the end of the python run.

However:

- while python is running I get the following error (but code keeps on running) : ERROR: Unable to create file <C:\A_GRID\PM\Grass\GrassDB/Location_L3/PERMANENT/.tmp/1824.0>

- All values of the output raster seem to be equal to 0.0 when I try to access them through a Grass garray. But I open the raster in Grass GUI all, I can see raster values were correctly populated for the whole raster. I get a nice cost surface.

Here is the core of my code : (coord is an array containing coordinates of point in the reference system of the current region)

a = garray\.array\(\)



grass\.run\_command\(&quot;g\.remove&quot;, rast=cost\_output\)
grass\.run\_command\(&quot;r\.walk&quot;, elevation=&quot;mnt\_l3\_toulouse@PERMANENT&quot;, friction=&quot;mnt\_l3\_toulouse@PERMANENT&quot;, output=cost\_output, coordinate=\[p1\[0\],p1\[1\]\],\_lambda=0\)
       
a\.read\(cost\_output\)

for p2 in coord:

    x = int\(\(p2\[0\]\-w\)/ewres\)
    y = int\(\(n\-p2\[1\]\)/nsres\)

    print a\[y,x\]

Thanks in advance!

Pierric wrote:

Dear Grass community,

Salut Pierric :slight_smile:

I am trying to use r.walk from python and the output file seems to be
created correctly at the end of the python run.

However:

- while python is running I get the following error (but code keeps on
running) : ERROR: Unable to create file
<C:\A_GRID\PM\Grass\GrassDB/Location_L3/PERMANENT/.tmp/1824.0>

Just wild guessing: here is ^^^ a slash in the path-name. Is this valid in
Windows?

Nikos

[rest deleted]

Hello,

In fact the line of code that is causing the error is

a.read(cost_output) # a is a garray

At that moment it needs to create a temporary file but fails at building the correct path by putting slashes instead of back slashes (for windows) for his part. Isn't it a bug? Is there a possibility to give it the correct path?

ERROR: Unable to create file <C:\A_GRID\PM\Grass\GrassDB/Location_L3/PERMANENT/.tmp/29576.0>

Thank you,
Pierric

----- Mail original -----
De : Nikos Alexandris <nik@nikosalexandris.net>
À : grass-user@lists.osgeo.org; Pierric <pierric7@yahoo.com>
Cc :
Envoyé le : Mardi 2 juillet 2013 14h54
Objet : Re: [GRASS-user] r.walk output and garray

Pierric wrote:

Dear Grass community,

Salut Pierric :slight_smile:

I am trying to use r.walk from python and the output file seems to be
created correctly at the end of the python run.

However:

- while python is running I get the following error (but code keeps on
running) : ERROR: Unable to create file
<C:\A_GRID\PM\Grass\GrassDB/Location_L3/PERMANENT/.tmp/1824.0>

Just wild guessing: here is ^^^ a slash in the path-name. Is this valid in
Windows?

Nikos

[rest deleted]

Pierric:

- while python is running I get the following error (but code keeps on
running) : ERROR: Unable to create file
<C:\A_GRID\PM\Grass\GrassDB/Location_L3/PERMANENT/.tmp/1824.0>

Nikos:

Just wild guessing: here is ^^^ a slash in the path-name. Is this valid in
Windows?

Yeah I think it is valid in that context actually, even if it looks weird.

I'd check if the .tmp/ directory really exists and if you can create new files there by hand.

Hamish

ps- using PERMANENT as the day-to-day working mapset is not recommended.