[Fwd: [Gdal-dev] gdal_array.SaveArray problem]
Vincent Schut
schut at sarvision.nl
Mon Jun 18 04:17:05 EDT 2007
Folks,
did nobody notice this post of mine of 2 weeks ago (see below), or does
nobody know an answer?
I hope someone can at least shed a little ray of light on it... I prefer
to post problems to the ml first, before filing a bug, because of the
larger audience and the simple fact that it might just be my fault
instead of a bug. I'll file a bug anyway if I get no response...
Vincent.
-------- Original Message --------
Subject: [Gdal-dev] gdal_array.SaveArray problem
Date: Tue, 05 Jun 2007 12:14:13 +0200
From: Vincent Schut <schut at sarvision.nl>
Organization: sarvision.nl
To: gdal-dev at lists.maptools.org
Hi folks,
the ngpython gdal_array.SaveArray method does something picky with my
arrays... When I try to access the array I have saved, I get a segfault.
When saving a copy of the array, everything goes fine.
This code segfaults:
#!/usr/bin/python
import gdal, gdal_array, numpy
a = numpy.arange(3*100*150, dtype=numpy.uint16).reshape((3, 100, 150))
gdal_array.SaveArray(a, "gdalSaveArrayTest.tif")
print a[0,0,0] # segfaults here.
And this code does not segfault:
#!/usr/bin/python
import gdal, gdal_array, numpy
a = numpy.arange(3*100*150, dtype=numpy.uint16).reshape((3, 100, 150))
gdal_array.SaveArray(a.copy(), "gdalSaveArrayTest.tif")
print a[0,0,0] # OK
Apparently it has something to do with refcounts; try this in a python
interpreter (a is a numpy array):
>>> gdal_array.SaveArray(a, "test.tif")
<gdal.Dataset; proxy of <Swig Object of type 'GDALDatasetShadow *' at
0xb57fa0> >
>>> a
<refcnt -4294967291 at 0x9648c0>
This is with gdal from recent svn, and numpy too.
_______________________________________________
Gdal-dev mailing list
Gdal-dev at lists.maptools.org
http://lists.maptools.org/mailman/listinfo/gdal-dev
More information about the Gdal-dev
mailing list