Pascal Leroux
2012-05-28 07:35:38 UTC
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 at 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.
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)))'
1.0000000000000000, 1.0000000000000000 1.0000000000000000,
2.0000000000000000 1.0000000000000000, 2.0000000000000000
0.0000000000000000, 1.0000000000000000 0.0000000000000000,
0.0000000000000000 0.0000000000000000))'
...
plx at sony:~$
Cascaded_union might be kept for compatibility reasons but it could call
GEOSUnarayUnion too ?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gispython.org/pipermail/community/attachments/20120528/bff9f36f/attachment.htm>
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 at 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)))')mp=loads('MULTIPOLYGON (((0 0,0 1,1 1,1 0, 0 0)), ((2 2, 2 3, 3 3, 3 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>from shapely.ops import unary_union as u2
u2((mp,p))
u2((mp,p)).wkt
'MULTIPOLYGON (((0.0000000000000000 0.0000000000000000, 0.00000000000000001.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.00000000000000001.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))
Trueu2(multi).equals(cu(multi))
...
cu((mp,p))
Erreur de segmentation (core dumped)plx at sony:~$
Cascaded_union might be kept for compatibility reasons but it could call
GEOSUnarayUnion too ?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gispython.org/pipermail/community/attachments/20120528/bff9f36f/attachment.htm>