Opened 17 years ago

Closed 16 years ago

#1952 closed defect (fixed)

Cannot pass buffer array to ReadAsArray (NG bindings)

Reported by: gebner Owned by: hobu
Priority: normal Milestone: 1.5.0
Component: PythonBindings Version: unspecified
Severity: normal Keywords:
Cc:

Description

Passing something else than buf_obj=None to ReadAsArray doesn't work:

>>> from osgeo import gdal
>>> from numpy import *
>>> ds = gdal.Open("foo.tif")
>>> tmp = zeros((100,100))
>>> ds.GetRasterBand(1).ReadAsArray(0,0, 100,100, 100,100, tmp)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "build/bdist.linux-x86_64/egg/osgeo/gdal.py", line 741, in ReadAsArray
  File "build/bdist.linux-x86_64/egg/osgeo/gdal_array.py", line 134, in BandReadAsArray
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
>>> ds.GetRasterBand(1).ReadAsArray(0,0, 100,100, 100,100)
array([[194, 193, 190, ..., 197, 195, 195],
       [190, 192, 194, ..., 198, 198, 199],
       [192, 194, 194, ..., 197, 198, 198],
       ..., 
       [200, 199, 200, ..., 203, 201, 201],
       [196, 197, 197, ..., 202, 201, 200],
       [195, 196, 197, ..., 202, 199, 199]], dtype=uint8)

Change History (3)

comment:1 by hobu, 17 years ago

Milestone: 1.5.0
Status: newassigned

Fixed in r12585. We can't test for existence the way we were doing before... Please test and confirm before I will close.

comment:2 by hobu, 16 years ago

Declaring dead for lack of followup

comment:3 by hobu, 16 years ago

Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.