Hi, Martin

With the same configuration (almost, Python 2.6.5 instead of 2.6.1) and with
a shapefile "TM_WORLD_BORDERS-0.3" downloaded from http://geocommons.com,
I've got no problems invoking the method "intersection" for France with
Spain as parameter. Is this the same shapefile you've used ?

Pascal

2011/1/9 Martin Laloux <[email protected]>

> Hello, I have a problem with multipolygon intersection
> >>> import osgeo.ogr
> >>> import shapely.wkt
> >>> from shapely.geometry import MultiPolygon
> >>> shapefile = osgeo.ogr.Open("TM_WORLD_BORDERS-0.3.shp")
> >>> layer = shapefile.GetLayer(0)
> >>> espagne = None
> >>> france = None
> >>> for i in range (layer.GetFeatureCount()):
> ...     feature = layer.GetFeature(i)
> ...     if feature.GetField("ISO2") == "FR":
> ...         geometry = feature.GetGeometryRef()
> ...         france=shapely.wkt.loads(geometry.ExportToWkt())
> ...     if feature.GetField("ISO2") == "ES":
> ...         geometry = feature.GetGeometryRef()
> ...         espagne=shapely.wkt.loads(geometry.ExportToWkt())
>
> >>> print france.wkt
> MULTIPOLYGON (((9.4858320000001299 42.6152730000001156, ...
> >>> print espagne.wkt
> MULTIPOLYGON (((-17.9127809999999386 27.7716640000000439, ...
> >>> france.intersects(espagne)
> True
> >>> x = france.intersection(espagne)
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
>   File
> "/Library/Python/2.6/site-packages/Shapely-1.2.8-py2.6.egg/shapely/geometry/base.py",
> line 331, in intersection
>     return geom_factory(self.impl['intersection'](self, other))
>   File
> "/Library/Python/2.6/site-packages/Shapely-1.2.8-py2.6.egg/shapely/topology.py",
> line 55, in __call__
>     "This operation produced a null geometry. Reason: unknown")
> shapely.geos.TopologicalError: This operation produced a null geometry.
> Reason: unknown
>
> I am on Mac OS X 10.6 with 64bits Python 2.6.1
> Is it a problem of the geos library or Shapely ?
> Thanks
> Martin
>
> _______________________________________________
> Community mailing list
> [email protected]
> http://lists.gispython.org/mailman/listinfo/community
>
>
_______________________________________________
Community mailing list
[email protected]
http://lists.gispython.org/mailman/listinfo/community

Reply via email to