We have run into the same issue before. I can completely see where Sean is
coming from when saying it is probably not a good idea to make
GeometryCollection's first class citizens. With that said, we ran into a
situation where we had no choice but to create the geometry collections.
The attached code is not pretty and is probably considered a complete hack,
but it accomplished what we needed.

-Aron

On Mon, Mar 5, 2012 at 10:44 AM, Harasty, Daniel J
<[email protected]>wrote:

> Sean:
>
> You mentioned:
>
> > I'm reluctant to make heterogeneous geometry collections first-class
> objects in Shapely,
> > mostly because GEOS (the lib under Shapely) generally disallows any
> operations on them.
>
> > For what it's worth, Shapely will happily write invalid multipolygons to
> WKT....
>
> > Thanks to the design of WKT, it's trivial to serialize a list of
> geometries to WKT like this:
> > "GEOMETRYCOLLECTION (%s)" % ", ".join(g.wkt for g in geometries)
>
> > Will that get you by?
>
> Thanks!  The second tip (doing the "GEOMETRYCOLLECTION".join([...])) was
> my "fallback plan".
>
> I'll investigate the "intentional invalid Multipolygon" trick, too.
>
> I do need to be able to read and reconstitute whatever serialization I
> choose (in Python with Shapely), so I'll have to make sure that Shapely can
> "round trip" either of those options.  Also, I do have the additional
> requirements that whatever I create has to be readable/bufferable by our
> system's SQL server.
>
> If either of the above work, then I'm good.
>
> Thanks again,
>
> Dan
>
> _______________________________________________
> Community mailing list
> [email protected]
> http://lists.gispython.org/mailman/listinfo/community
>

Attachment: create_geom_collection.py
Description: Binary data

_______________________________________________
Community mailing list
[email protected]
http://lists.gispython.org/mailman/listinfo/community

Reply via email to