Discussion:
[Community] MultiPolygon union Polygon not MultiPolygon?
Juan Pablo Caram
2014-04-13 04:56:24 UTC
Permalink
Hi,
type(my_multi)==MultiPolygon
True
type(a_poly)==Polygon
True
u = my_multi.union(a_poly)
type(u)
GeometryCollection

Is this at all possible? The GeometryCollection has a LineString!

The Multipolygon is huge. Starts with

MULTIPOLYGON (((31.75 98.55250000000001, 32.766 98.55250000000001, 191.516
98.55250000000001, 191.5160490085702 98.55249759236334, 191.516097545161
98.55249039264021, 191.5161451423386 98.55247847016787, 191.5161913417162
98.55246193976626, 191.5162356983684 98.55244096063218, 191.5162777851165
98.55241573480616, 191.5163171966421 98.55238650522669, 191.5163535533906
98.5523535533906, 191.5163865052267 98.55231719664209, 191.5164157348062
98.55227778511652, 191.5164409606322 98.55223569836842, 191.5164619397663
98.5521913417162, 191.5164784701679 98.55214514233863, 191.5164903926402
98.55209754516102,

The Polygon is

POLYGON ((206.0975 -0.8160000000000005, 206.0971942301437
-0.8222240884109276, 206.0962798653056 -0.8283882354480248,
206.094765711319 -0.8344330770056589, 206.0926663503145
-0.8403003979551837, 206.0900020002861 -0.8459336927884514,
206.0867983203812 -0.8512787097967453, 206.0830861637885
-0.856283973544392, 206.0789012806054 -0.8609012806053463,
206.0742839735444 -0.8650861637885343, 206.0692787097968
-0.8687983203812122, 206.0639336927885 -0.8720020002861211,
206.0583003979552 -0.8746663503144673, 206.0524330770057
-0.8767657113189957, 206.046388235448 -0.8782798653056056,
206.0402240884109 -0.879194230143685, 206.034 -0.8795000000000005,
206.0277759115891 -0.879194230143685, 206.021611764552 -0.8782798653056056,
206.0155669229943 -0.8767657113189957, 206.0096996020448
-0.8746663503144673, 206.0040663072115 -0.8720020002861211,
205.9987212902032 -0.8687983203812122, 205.9937160264556
-0.8650861637885343, 205.9890987193946 -0.8609012806053463,
205.9849138362115 -0.8562839735443921, 205.9812016796188
-0.8512787097967454, 205.9779979997139 -0.8459336927884515,
205.9753336496855 -0.8403003979551839, 205.973234288681
-0.8344330770056591, 205.9717201346944 -0.8283882354480249,
205.9708057698563 -0.8222240884109279, 205.9705 -0.8160000000000008,
205.9708057698563 -0.8097759115890729, 205.9717201346944
-0.8036117645519758, 205.973234288681 -0.7975669229943416,
205.9753336496855 -0.7916996020448168, 205.9779979997139
-0.7860663072115491, 205.9812016796188 -0.7807212902032552,
205.9849138362115 -0.7757160264556086, 205.9890987193946
-0.7710987193946542, 205.9937160264556 -0.7669138362114663,
205.9987212902032 -0.7632016796187884, 206.0040663072115
-0.7599979997138795, 206.0096996020448 -0.7573336496855333,
206.0155669229943 -0.7552342886810048, 206.021611764552
-0.7537201346943949, 206.0277759115891 -0.7528057698563155, 206.034
-0.7525000000000001, 206.0402240884109 -0.7528057698563155,
206.046388235448 -0.7537201346943949, 206.0524330770057
-0.7552342886810048, 206.0583003979552 -0.7573336496855333,
206.0639336927885 -0.7599979997138795, 206.0692787097968
-0.7632016796187884, 206.0742839735444 -0.7669138362114663,
206.0789012806054 -0.7710987193946542, 206.0830861637885
-0.7757160264556084, 206.0867983203812 -0.7807212902032552,
206.0900020002861 -0.786066307211549, 206.0926663503145
-0.7916996020448167, 206.094765711319 -0.7975669229943415,
206.0962798653056 -0.8036117645519757, 206.0971942301437
-0.8097759115890727, 206.0975 -0.8159999999999997, 206.0975
-0.8160000000000005))

Thanks,

JP
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gispython.org/pipermail/community/attachments/20140413/d2765c32/attachment.htm>
Mike Toews
2014-04-13 09:56:48 UTC
Permalink
Post by Juan Pablo Caram
Hi,
Is this at all possible? The GeometryCollection has a LineString!
Sure, this is possible. A union can return any type of geometry, from
GEOMETRYCOLLECTION EMPTY to POINT to anything else. If the result is a
LINESTRING, then the union of the two geometries share a boundary. If
it is in a GEOMETRYCOLLECTION, then there is a mixture of types in the
same result, such as POINT and POLYGON parts. All these are possible,
and not so strange when you look at them drawn out.

-Mike
Juan Pablo Caram
2014-04-13 16:20:48 UTC
Permalink
Hi Mike,
I understand the basic concept of a union and resulting type, but how can
the union of polygons result in anything but polygons?
Thanks,
JP
Post by Mike Toews
Post by Juan Pablo Caram
Hi,
Is this at all possible? The GeometryCollection has a LineString!
Sure, this is possible. A union can return any type of geometry, from
GEOMETRYCOLLECTION EMPTY to POINT to anything else. If the result is a
LINESTRING, then the union of the two geometries share a boundary. If
it is in a GEOMETRYCOLLECTION, then there is a mixture of types in the
same result, such as POINT and POLYGON parts. All these are possible,
and not so strange when you look at them drawn out.
-Mike
_______________________________________________
Community mailing list
Community at lists.gispython.org
http://lists.gispython.org/mailman/listinfo/community
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gispython.org/pipermail/community/attachments/20140413/6b146c5e/attachment.htm>
Mike Toews
2014-04-13 18:52:24 UTC
Permalink
Post by Juan Pablo Caram
Hi Mike,
I understand the basic concept of a union and resulting type, but how can
the union of polygons result in anything but polygons?
Post by Juan Pablo Caram
Thanks,
JP
For example, given the range of incomplete coordinates in your example, the
two polygons appear to be disjoint, thus the result is GEOMETRYCOLLECTION
EMPTY. Is there any specific example where a polygon overlap was expected?
Sometimes invalid geometries muddle with these algorithms that may yield
unexpected results.

-Mike
Hi Mike,
I understand the basic concept of a union and resulting type, but how can
the union of polygons result in anything but polygons?
Thanks,
JP
Post by Juan Pablo Caram
Post by Juan Pablo Caram
Hi,
Is this at all possible? The GeometryCollection has a LineString!
Sure, this is possible. A union can return any type of geometry, from
GEOMETRYCOLLECTION EMPTY to POINT to anything else. If the result is a
LINESTRING, then the union of the two geometries share a boundary. If
it is in a GEOMETRYCOLLECTION, then there is a mixture of types in the
same result, such as POINT and POLYGON parts. All these are possible,
and not so strange when you look at them drawn out.
-Mike
_______________________________________________
Community mailing list
Community at lists.gispython.org
http://lists.gispython.org/mailman/listinfo/community
_______________________________________________
Community mailing list
Community at lists.gispython.org
http://lists.gispython.org/mailman/listinfo/community
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gispython.org/pipermail/community/attachments/20140414/732c5d6e/attachment.htm>
Juan Pablo Caram
2014-04-14 00:44:46 UTC
Permalink
I'll check for invalid polygons and will get back to you.
Thanks a lot,
JP
Post by Juan Pablo Caram
Hi Mike,
I understand the basic concept of a union and resulting type, but how
can the union of polygons result in anything but polygons?
Post by Juan Pablo Caram
Thanks,
JP
For example, given the range of incomplete coordinates in your example,
the two polygons appear to be disjoint, thus the result is
GEOMETRYCOLLECTION EMPTY. Is there any specific example where a polygon
overlap was expected? Sometimes invalid geometries muddle with these
algorithms that may yield unexpected results.
-Mike
Hi Mike,
I understand the basic concept of a union and resulting type, but how can
the union of polygons result in anything but polygons?
Thanks,
JP
Post by Juan Pablo Caram
Post by Juan Pablo Caram
Hi,
Is this at all possible? The GeometryCollection has a LineString!
Sure, this is possible. A union can return any type of geometry, from
GEOMETRYCOLLECTION EMPTY to POINT to anything else. If the result is a
LINESTRING, then the union of the two geometries share a boundary. If
it is in a GEOMETRYCOLLECTION, then there is a mixture of types in the
same result, such as POINT and POLYGON parts. All these are possible,
and not so strange when you look at them drawn out.
-Mike
_______________________________________________
Community mailing list
Community at lists.gispython.org
http://lists.gispython.org/mailman/listinfo/community
_______________________________________________
Community mailing list
Community at lists.gispython.org
http://lists.gispython.org/mailman/listinfo/community
_______________________________________________
Community mailing list
Community at lists.gispython.org
http://lists.gispython.org/mailman/listinfo/community
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gispython.org/pipermail/community/attachments/20140413/7c10c719/attachment.htm>
Pimin Konstantin Balic Kefaloukos
2014-04-14 08:09:28 UTC
Permalink
Mike, seems to me that you're confusing union with intersection. A union
between valid polygons (including multipolygons) will always return a
polygon or multipolygon.
On 13 April 2014 16:56, Juan Pablo Caram <jpcaram at gmail.com <javascript:;>>
Post by Juan Pablo Caram
Hi,
Is this at all possible? The GeometryCollection has a LineString!
Sure, this is possible. A union can return any type of geometry, from
GEOMETRYCOLLECTION EMPTY to POINT to anything else. If the result is a
LINESTRING, then the union of the two geometries share a boundary. If
it is in a GEOMETRYCOLLECTION, then there is a mixture of types in the
same result, such as POINT and POLYGON parts. All these are possible,
and not so strange when you look at them drawn out.
-Mike
_______________________________________________
Community mailing list
Community at lists.gispython.org <javascript:;>
http://lists.gispython.org/mailman/listinfo/community
--
Pimin Konstantin Bali? Kefaloukos

Anders Henriksens Gade 3, 2th
2300 Copenhagen S
Denmark
Phone: +45 2611 6003
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gispython.org/pipermail/community/attachments/20140414/c23a3593/attachment-0001.htm>
Mike Toews
2014-04-14 09:11:26 UTC
Permalink
On 14 April 2014 20:09, Pimin Konstantin Balic Kefaloukos
Post by Pimin Konstantin Balic Kefaloukos
Mike, seems to me that you're confusing union with intersection. A union
between valid polygons (including multipolygons) will always return a
polygon or multipolygon.
Ah, I see it's been a while since I've had a good look at a Venn diagram!
Loading...