Re: [GRASS-dev] error in pygrass doc

2016-01-11 Thread Luca Delucchi
On 8 January 2016 at 17:21, Pietro  wrote:
> Hi Luca,
>

Hi all,

>
> please replace the example with enumerate.
>

done in r67547 and r67548

> All the best
>
> Pietro



-- 
ciao
Luca

http://gis.cri.fmach.it/delucchi/
www.lucadelu.org
___
grass-dev mailing list
grass-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-dev

Re: [GRASS-dev] error in pygrass doc

2016-01-08 Thread Pietro
Hi Luca,


On Fri, Jan 8, 2016 at 10:18 AM, Luca Delucchi  wrote:
 for irow in xrange(elev.rows):
> ...new[irow] = elev[irow] < 144
> ...
> Traceback (most recent call last):
>   File "", line 1, in 
> AttributeError: 'RasterSegment' object has no attribute 'rows'

Thanks to discover this bad documentation page.

instead of elev.rows it is possible to use len(elev) to get the number
of rows, and insetad usig a variable to get the row number use just:

{{{
for irow, row in enumerate(elev):
new[irow] = row < 144
}}}

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

please replace the example with enumerate.

All the best

Pietro
___
grass-dev mailing list
grass-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-dev

[GRASS-dev] error in pygrass doc

2016-01-08 Thread Luca Delucchi
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 "", line 1, in 
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
___
grass-dev mailing list
grass-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-dev