[GRASS-dev] error in pygrass doc

Luca Delucchi lucadeluge at gmail.com
Fri Jan 8 01:18:50 PST 2016


Hi devs,

A friend found the following problem in the raster pygrass documentation [0]

>>> elev=RasterSegment('elevation_raster')
>>> elev.open()
>>> for row in elev[:5]: print(row[:3])
...
[ 1.77111459  1.78603125  1.79853868]
[ 1.76286662  1.78353381  1.79924631]
[ 1.74902475  1.77574825  1.79443765]
[ 1.72868252  1.75860429  1.7779566 ]
[ 1.70507514  1.73153877  1.74640989]
>>> new =RasterSegment('new')
>>> new.open('w', 'CELL')
>>> for irow in xrange(elev.rows):
KeyboardInterrupt
>>> for irow in xrange(elev.rows):
...        new[irow] = elev[irow] < 144
...
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'RasterSegment' object has no attribute 'rows'


I suggest him to use

x = 0
for irow in elev:
    new[x] = irow<144
    x += 1


maybe there is a better solution, otherwise I can replace the wrong
code in the doc with this solution.

[0] https://grass.osgeo.org/grass71/manuals/libpython/pygrass_raster.html#rastersegment-label

-- 
ciao
Luca

http://gis.cri.fmach.it/delucchi/
www.lucadelu.org


More information about the grass-dev mailing list