Ticket #1952 (closed defect: fixed)

Opened 6 years ago

Last modified 5 years ago

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

Changed 6 years ago by hobu

  • status changed from new to assigned
  • milestone set to 1.5.0

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

Changed 5 years ago by hobu

Declaring dead for lack of followup

Changed 5 years ago by hobu

  • status changed from assigned to closed
  • resolution set to fixed
Note: See TracTickets for help on using tickets.