[GRASS-user] Pygrass reading raster issue

Hi all,

I’m tring to read a raster map from my grassData.

I’m using this code

import os
import grass.script.setup as gsetup
from grass.pygrass import raster

gisbase = os.environ[‘GISBASE’]
gisdbase = os.path.abspath(“/home/myuser/grassData”)
location = ‘mylocation’
mapset = ‘mymapset’
gsetup.init(gisbase, gisdbase, location, mapset)

elev=raster.RasterRow(‘elevation’)
elev.open()
for row in elev:
print row

But I get all values with nan, where is the error?

If I do [elev.info](http://elev.info)() I get this result

elevation@
rows: 4502
cols: 5554
north: 45.0743663458 south: 45.0500262069 nsres:5.40651685671e-06
east: 7.67457811722 west: 7.6445503225 ewres:5.40651687473e-06
range: 233.050003052, 310.049987793
proj: 3

Tnx

Lorenzo

Le Mon, 14 Mar 2016 13:45:42 +0100,
Lorenzo Bottaccioli <lorenzo.bottaccioli@gmail.com> a écrit :

Hi all,

I'm tring to read a raster map from my grassData.

I'm using this code

    import os
    import grass.script.setup as gsetup
    from grass.pygrass import raster

    gisbase = os.environ['GISBASE']
    gisdbase = os.path.abspath("/home/myuser/grassData")
    location = 'mylocation'
    mapset = 'mymapset'
    gsetup.init(gisbase, gisdbase, location, mapset)

    elev=raster.RasterRow('elevation')
    elev.open()
    for row in elev:
        print row

But I get all values with nan, where is the error?

If I do `elev.info()` I get this result

    elevation@
    rows: 4502
    cols: 5554
    north: 45.0743663458 south: 45.0500262069 nsres:5.40651685671e-06
    east: 7.67457811722 west: 7.6445503225 ewres:5.40651687473e-06
    range: 233.050003052, 310.049987793
    proj: 3

Check your computational region settings.

Moritz

Region is Ok!

···

2016-03-14 14:45 GMT+01:00 Moritz Lennert <mlennert@club.worldonline.be>:

Le Mon, 14 Mar 2016 13:45:42 +0100,
Lorenzo Bottaccioli <lorenzo.bottaccioli@gmail.com> a écrit :

Hi all,

I’m tring to read a raster map from my grassData.

I’m using this code

import os
import grass.script.setup as gsetup
from grass.pygrass import raster

gisbase = os.environ[‘GISBASE’]
gisdbase = os.path.abspath(“/home/myuser/grassData”)
location = ‘mylocation’
mapset = ‘mymapset’
gsetup.init(gisbase, gisdbase, location, mapset)

elev=raster.RasterRow(‘elevation’)
elev.open()
for row in elev:
print row

But I get all values with nan, where is the error?

If I do [elev.info](http://elev.info)() I get this result

elevation@
rows: 4502
cols: 5554
north: 45.0743663458 south: 45.0500262069 nsres:5.40651685671e-06
east: 7.67457811722 west: 7.6445503225 ewres:5.40651687473e-06
range: 233.050003052, 310.049987793
proj: 3

Check your computational region settings.

Moritz

>> [...] nsres:5.40651685671e-06
>> [...] ewres:5.40651687473e-06

Region is Ok!

g.region -p ?

-----
best regards
Helmut
--
View this message in context: http://osgeo-org.1560.x6.nabble.com/Pygrass-reading-raster-issue-tp5256213p5256279.html
Sent from the Grass - Users mailing list archive at Nabble.com.

g.region(‘-p’)
Out[40]:
{‘b’: 0.0,
‘cells’: 25004108,
‘cells3’: 25004108,
‘cols’: 5554,
‘cols3’: 5554,
‘depths’: 1,
‘e’: 7.67457811722222,
‘ewres’: 5.40651687472501e-06,
‘ewres3’: 5.40651687472501e-06,
‘n’: 45.0743663458333,
‘nsres’: 5.40651685670714e-06,
‘nsres3’: 5.40651685670714e-06,
‘rows’: 4502,
‘rows3’: 4502,
‘s’: 45.0500262069444,
‘t’: 1.0,
‘tbres’: 1.0,
‘w’: 7.6445503225}

before I have set g.region(‘raster=elevation’)

So the region should be OK!

···

2016-03-14 18:10 GMT+01:00 Helmut Kudrnovsky <hellik@web.de>:

[…] nsres:5.40651685671e-06
[…] ewres:5.40651687473e-06
Region is Ok!

g.region -p ?


best regards
Helmut

View this message in context: http://osgeo-org.1560.x6.nabble.com/Pygrass-reading-raster-issue-tp5256213p5256279.html
Sent from the Grass - Users mailing list archive at Nabble.com.


grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

Lorenzo Bottaccioli wrote

g.region('-p')
Out[40]:
{'b': 0.0,
'cells': 25004108,
'cells3': 25004108,
'cols': 5554,
'cols3': 5554,
'depths': 1,
'e': 7.67457811722222,
'ewres': 5.40651687472501e-06,
'ewres3': 5.40651687472501e-06,
'n': 45.0743663458333,
'nsres': 5.40651685670714e-06,
'nsres3': 5.40651685670714e-06,
'rows': 4502,
'rows3': 4502,
's': 45.0500262069444,
't': 1.0,
'tbres': 1.0,
'w': 7.6445503225}

before I have set g.region('raster=elevation')

So the region should be OK!

2016-03-14 18:10 GMT+01:00 Helmut Kudrnovsky &lt;

hellik@

&gt;:

>> [...] nsres:5.40651685671e-06
>> [...] ewres:5.40651687473e-06
> Region is Ok!

g.region -p ?

'ewres': 5.40651687472501e-06,
'nsres': 5.40651685670714e-06

it looks like a very small resolution and not equally in N-S and W-E

'n': 45.0743663458333 - 's': 45.0500262069444 = 0.024340139

-----
best regards
Helmut
--
View this message in context: http://osgeo-org.1560.x6.nabble.com/Pygrass-reading-raster-issue-tp5256213p5256282.html
Sent from the Grass - Users mailing list archive at Nabble.com.