ReadAsArray in python/numpy gdal bindings should take pointer to preallocated memory
|Reported by:||jaredrubinaz||Owned by:||hobu|
|Severity:||major||Keywords:||numpy python readasarray|
When using the C++ side of gdal with the numpy/python bindings. I would expect that a preallocated array would be generated from numpy and a pointer to the beginning of the memory buffer would be passed to gdal.
Currently the BandReadAsArray method in gdal_array.py is not even using the buf_obj that is passed in. If a buf_obj is passed in it overrides it with a new numpy array. This makes no sense. This method should just use the buf_obj
129 if buf_obj is not None: 130 buf_obj = numpy.zeros( shape, typecode ) 131 132 band_str = band.ReadRaster( xoff, yoff, win_xsize, win_ysize, 133 buf_xsize, buf_ysize, datatype ) 134 ar = numpy.fromstring(band_str,dtype=typecode) 135 ar = numpy.reshape(ar, [buf_ysize,buf_xsize])
allocates the memory for the
RasterIO call, can one not have numpy allocate the memory and then pass
a pointer to the gdal/swig bindings?