[gdal-dev] Python Bindings - ReadArray direct to ctypes array?

Chris Barker chris.barker at noaa.gov
Sun Jul 29 14:20:48 PDT 2012


On Fri, Jul 27, 2012 at 8:40 PM, Jay L. <jzl5325 at psu.edu> wrote:

> Currently the workflow is to open the dataset and grab the first band, as
> usual. I then read in the array, create an empty ctype array, and use
> memmove to move the numpy array to my ctypes array.

numpy comes with some utilities for working with ctypes and numpy
arrays -- you certainly should be able to do that without a copy. Poke
around in the numyp source, docs, and mailing list.

If I understand the docs right, this makes it really simple:

http://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.ctypes.html

note that there is a lot of great stuff going on with numpy and
Cython doing this sort of stuff -- numpy arrays may be a good bet anyway.


You might also want to check out geo-Dango -- I think they've got a
pretty complete wrapper for GDAL with ctypes

-Chris



-- 

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov


More information about the gdal-dev mailing list