Hi,

I am running a Debian/Sid system and face a problem when using the gdal
python bindinds.

The gdal python bindings are linked with Numeric. In one of my
application i'm using some numpy methods. This is working fine BUT when
I add the use of the matploblib library to my application all the calls
to gdal specific methods are broken.

I have attached a basic example. The first test fails if I import the
pylab module. The second one that can be run with any shapefile shows
that when pylab is loaded, some GDAL methods raises GEOS exceptions.
Commenting the "import pylab" line shows that without pylab there is no
exceptions, nor problems.

They are two workarounds :
[1] a real one : using matplotlib with the Numeric lib
[2] a fake one :
renaming /usr/lib/python2.4/site-packages/numpy/core/multiarray.so to
another name, the tests does not fail.

Does anybody have a suggestion to correct this problem ?

I can provide more details if needed.

Best regards,

--
Didrik
'''
Pylab - numpy - Numeric - gdal interaction problem

Author : Didrik Pinte <[EMAIL PROTECTED]>
Date   : 30 may 2006
'''
import unittest
import ogr

#import pylab

class TestIntersection(unittest.TestCase):
    
    def test_polyintersection(self):
        '''
        Test that surface intersection between two polygons returns a polygon
        '''

        t1wkt = 'POLYGON ((-1.0 50.5, -0.5 51.2, 0.3 50.9, -1 50.5))'
        t2wkt = 'POLYGON((-0.7 50.3, 0.1 51.0, 0.6 50.1, -0.7 50.3))'

        t1 = ogr.CreateGeometryFromWkt(t1wkt)
        t2 = ogr.CreateGeometryFromWkt(t2wkt)

        int1  = t1.Intersection(t2)
        self.assertEqual(int1.GetGeometryType(), ogr.wkbPolygon)


    def test_fromfile(self):
        '''
        Test some simple disjoint and intersection between features of a
        shapefile
        '''       
        datasource  = ogr.Open('/home/did/Documents/ucl/alert/python/alert/test/scenario1/polygones.shp', update=0)
        layer = datasource.GetLayer()
        layer.ResetReading()
        object1 = layer.GetFeature(0)
        geom1 = object1.GetGeometryRef()
        layer.SetSpatialFilterRect(*geom1.GetEnvelope())
        layer.ResetReading() 
        object2 = layer.GetNextFeature()
        geom2 = object2.GetGeometryRef()
        self.assertEqual(geom1.Disjoint(geom2), False)
        intersection = geom1.Intersection(geom2)

if __name__ == '__main__':
    unittest.main()

Attachment: signature.asc
Description: Ceci est une partie de message numériquement signée

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion

Reply via email to