logo       

Re: GDALNumeric.SaveArray : Unable to access numpy arrays of typecode "@": msg#00157

gis.gdal.devel

Subject: Re: GDALNumeric.SaveArray : Unable to access numpy arrays of typecode "@"

Hi,

I had the same problem. This was Frank's response (his -DHAVE_NUMPY solution worked for me):

This might be an issue with how GDAL is built on windows. If GDAL doesn't
"know" how to find Numeric/arrayobject.h to get at the definitions of
the PaArray_Descr and PyArrayObject structures it just falls back to using
internal declarations for these presumably copied from an earlier version
of Python. To the best of my knowledge the internal (out of date) definitions
are always used on windows.

Try adding -DHAVE_NUMPY to OPTFLAGS in nmake.opt and see if things work.

The easiest way to verify you are getting system definitions of the numpy
stuff would be to add a #error directive in the "#ifndef HAVE_NUMPY" section
of gdal/pymod/gdal_py.h.

- Gillian

Gagan Tandon wrote:

Dear Friends,

I am using Numeric 23.0 version and python 2.3 on a windows XP machine. I have build GDAL from MS VC++ and Visual Studio .net and installed on my machine. The GDAL version is 1.1.9.

Basic Problem : I am trying to save a Numpy array(infact the primary issue is to save any 2d array (not just NUMPY) to a "TIF" file) to a TIF file. When I run the following commands, I get an error stating that it cannot access Numpy array of typecode "@" (weird..??)

DUMP OF PYTHON INTERPRETER.

>>> k = Numeric.zeros((2,2),"f")

>>> k
array([[ 0., 0.],
[ 0., 0.]],'f') // I have tried with array k = array([[1.2, 2.3], [2.5,1.7]],"f")


>>> import gdalnumeric

>>> gdalnumeric.SaveArray(k,"k.tif")
ERROR 1: Unable to access numpy arrays of typecode `@' <mailto:%60@%27>.

Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "C:\GDAL\pymod\gdalnumeric.py", line 97, in SaveArray
return driver.CreateCopy( filename, OpenArray(src_array,prototype) )
File "C:\GDAL\pymod\gdal.py", line 330, in CreateCopy
target_ds = _gdal.GDALCreateCopy( self._o, filename, source_ds._o,
AttributeError: 'NoneType' object has no attribute '_o'

---- END OF PYTHON INTERPRETER

I am wondering whether this is a version problem with Numeric python or is it a problem with the building of GDAL using MS VC++ 7.0 or is it something else. I would be delighted if any one can give me clues on how to save a 2d array to a TIF file, since thats the primary problem.

Thanks

Gagan Tandon

------------------------------------------------------------------------
------------------------------------------------------------------------

Gagan Tandon
Research Assistant
GIS and Remote Sensing
Colorado State University
------------------------------------------------------------------------
------------------------------------------------------------------------

------------------------------------------------------------------------
Attention all artisans! Sell Diwali creations online. Register now! <http://g.msn.com/8HMAENIN/2734??PS=> _______________________________________________ Gdal-dev mailing list Gdal-dev@xxxxxxxxxxxxxxxxx http://remotesensing.org/mailman/listinfo/gdal-dev


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise