Hi all,
Using a list containing polygons AND multipolygons, I have made the Python
interpreter crash (bus error on MacOSX, segmentation fault on
Linux/Ubuntu). Shapely.ops.cascaded_union only accepts a Polygon instance
list or a MultiPpolygon instance as a parameter.
In addition to that, GEOSCascadedUnion is deprecated from version 3.3.0 and
GEOSUnaryUnion must be used instead.
Why not to define in shapely.ops a function "unary_union" that would call
(wrap) GEOSUnaryUnion function ?
I've modified ctypes_declarations.py and ops.py to use GEOSUnaryUnion and
it seems to work :
plx@sony:~$ python
Python 2.7.3 (default, Apr 20 2012, 22:44:07)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from shapely.wkt import loads
>>> mp=loads('MULTIPOLYGON (((0 0,0 1,1 1,1 0, 0 0)), ((2 2, 2 3, 3 3, 3 2,
2 2)))')
>>> p=loads('POLYGON ((2 0, 2 1, 3 1, 3 0, 2 0))')
>>> from shapely.ops import unary_union as u2
>>> u2((mp,p))
<shapely.geometry.multipolygon.MultiPolygon object at 0xb6c9f9ac>
>>>
>>> u2((mp,p)).wkt
'MULTIPOLYGON (((0.0000000000000000 0.0000000000000000, 0.0000000000000000
1.0000000000000000, 1.0000000000000000 1.0000000000000000,
1.0000000000000000 0.0000000000000000, 0.0000000000000000
0.0000000000000000)), ((2.0000000000000000 0.0000000000000000,
2.0000000000000000 1.0000000000000000, 3.0000000000000000
1.0000000000000000, 3.0000000000000000 0.0000000000000000,
2.0000000000000000 0.0000000000000000)), ((2.0000000000000000
2.0000000000000000, 2.0000000000000000 3.0000000000000000,
3.0000000000000000 3.0000000000000000, 3.0000000000000000
2.0000000000000000, 2.0000000000000000 2.0000000000000000)))'
>>>
>>> multi=loads('MULTIPOLYGON (((0 0, 0 1, 1 1, 1 0, 0 0)), ((1 1, 2 1, 2
0, 1 0, 1 1)))')
>>> u2(multi).wkt
'POLYGON ((0.0000000000000000 0.0000000000000000, 0.0000000000000000
1.0000000000000000, 1.0000000000000000 1.0000000000000000,
2.0000000000000000 1.0000000000000000, 2.0000000000000000
0.0000000000000000, 1.0000000000000000 0.0000000000000000,
0.0000000000000000 0.0000000000000000))'
>>>
>>>
>>> from shapely.ops import cascaded_union as cu
>>> u2(multi).equals(cu(multi))
True
>>>
>>> # with polygons and multipolygons, cascaded_union :
...
>>>
>>> cu((mp,p))
Erreur de segmentation (core dumped)
plx@sony:~$
Cascaded_union might be kept for compatibility reasons but it could call
GEOSUnarayUnion too ?
_______________________________________________
Community mailing list
[email protected]
http://lists.gispython.org/mailman/listinfo/community