Ticket #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
Note: See
TracTickets for help on using
tickets.
