[Gdal-dev] Problem with gdalnumeric.SaveArray

Gillian Walter gillian.walter at vexcel.com
Mon Mar 20 19:32:52 EST 2006


Hi,

I have been running into a problem with gdalnumeric.SaveArray in the 
latest version of GDAL (using Fedora core 3 Linux, building GDAL from 
current CVS with Python 2.3.5 and Numeric 23.0) and I'm wondering if 
there's some sort of referencing issue.  If I enter the following 
commands in the Python shell, I get a core dump:

import Numeric
import gdalnumeric
arr=Numeric.array([[5.3,1,2],[6,7,8]]).astype(Numeric.Float32)
arr # print array
gdalnumeric.SaveArray(arr,'/home/gwalter/junk.tif')
arr # try to print array again- Segfaults instead of printing


But, if I separate the SaveArray out into its component commands:

import Numeric
import gdalnumeric
import gdal
dr = gdal.GetDriverByName("GTiff")
arr=Numeric.array([[5.3,1,2],[6,7,8]]).astype(Numeric.Float32)
arr # print array
ds=gdalnumeric.OpenArray(arr)
dr.CreateCopy('/home/gwalter/junk2.tif',ds)
arr # try to print array again

the print works fine.  I am wondering about referencing problems because 
  replacing:

ds=gdalnumeric.OpenArray(arr)
dr.CreateCopy('/home/gwalter/junk2.tif',ds)

with

dr.CreateCopy('/home/gwalter/junk2.tif',OpenArray(arr))

causes a segfault at the next array print.  Also, if you don't replace 
the two calls with one, but delete ds, the next array print will segfault.

I did not have this problem in an older version of gdal; I'm not sure 
when it crept in (I've been largely using a pre-PAM version of gdal). 
Is anyone else able to reproduce this problem?


Gillian





More information about the Gdal-dev mailing list