On Sep 17, 2009, at 6:48 PM, Mario Ceresa wrote: > Hi everybody! > I was curious to see new Shapely 1.1 in action and installed it in a > virtualenv as explained in > > http://sgillies.net/blog/900/diving-into-shapely-1-1/ > > but when I run the following code: > > from shapely.geometry import Point, Polygon > from random import random > spots = [Point(random()*2.0-0.5, random()*2.0-1.0).buffer(0.1) for i > in xrange(200)] > triangle = Polygon(((0.0, 0.0), (1.0, 1.0), (1.0, -1.0))) > x = [s for s in spots if triangle.intersects(s)] > > I get: > > Traceback (most recent call last): > File "prepared.py", line 5, in <module> > x = [s for s in spots if triangle.intersects(s)] > File "Download/try-shapely/lib/python2.5/site-packages/ > Shapely-1.1a4-py2.5.egg/shapely/geometry/base.py", > line 191, in intersects > return self._binaryGeometryPredicates.intersects(self, other) > File "Download/try-shapely/lib/python2.5/site-packages/ > shapely.geos-1.0a4-py2.5.egg/shapely/geos/predicates.py", > line 63, in __call__ > raise PredicateError, "Failed to evaluate %s in context %s and %s" > % (self.func.__name__, repr(context), repr(other)) > shapely.geos.PredicateError: Failed to evaluate GEOSIntersects_r in > context <shapely.geometry.polygon.Polygon object at 0x19e2310> and > <shapely.geometry.polygon.Polygon object at 0x19e25d0> > Exception exceptions.AttributeError: "'NoneType' object has no > attribute 'GEOSWKBWriter_destroy'" in <bound method > GEOSWKBWriter.__del__ of <shapely.geos.wkb.GEOSWKBWriter object at > 0x1a63750>> ignored > Exception exceptions.AttributeError: "'NoneType' object has no > attribute 'GEOSWKBReader_destroy'" in <bound method > GEOSWKBReader.__del__ of <shapely.geos.wkb.GEOSWKBReader object at > 0x1a636d0>> ignored > > Any idea on what I'm doing wrong? I use Geos 3.1.0 on a Fedora 10 > x64 system. > > Thanks and regards, > > Mario
Hi Mario, GEOS is complaining that it can't intersect two geometries. It's likely that there's a bug in shapely.geos, either in the code that computes the GEOS geometry from the Python coordinate sequence arrays, or in the caching of the geometry. I'm unable to reproduce the bug right now, but will look into it. Cheers, -- Sean _______________________________________________ Community mailing list [email protected] http://lists.gispython.org/mailman/listinfo/community
