One possible solution is:
>>> shapely.wkt.loads('GEOMETRYCOLLECTION (POINT (0.0 1.0), LINESTRING (0.0
0.0, 1.0 1.0), POLYGON((3.0 0.0, 4.0 0.0, 4.0 1.0, 3.0 0.0)))')
<shapely.geometry.collection.GeometryCollection object at 0xb74aa48c>
but this seems terribly awkward
On Tue, Nov 13, 2012 at 12:37 PM, Christian Ledermann <
[email protected]> wrote:
> I want to parse a kml like :
>
> <kml:MultiGeometry xmlns:kml="http://www.opengis.net/kml/2.2">
> <kml:Polygon>
> <kml:outerBoundaryIs>
> <kml:LinearRing>
> <kml:coordinates>3.000000,0.000000 4.000000,0.000000
> 4.000000,1.000000 3.000000,0.000000</kml:coordinates>
> </kml:LinearRing>
> </kml:outerBoundaryIs>
> </kml:Polygon>
> <kml:Point>
> <kml:coordinates>0.000000,1.000000</kml:coordinates>
> </kml:Point>
> <kml:LineString>
> <kml:coordinates>0.000000,0.000000 1.000000,1.000000</kml:coordinates>
> </kml:LineString>
> </kml:MultiGeometry>
>
>
> into a shapely geometry
>
>
> I tried
>
> po = Polygon([(3,0), (4,0), (4,1), (3,0)])
> l = LineString([(0,0), (1,1)])
> p = Point(0,1)
> g = GeometryCollection([po,p,l])
>
> which fails with:
> TypeError: __init__() takes exactly 1 argument (2 given)
> and
> geo_if = {'type': 'GeometryCollection', 'geometries': [
> po.__geo_interface__, l.__geo_interface__,
> p.__geo_interface__ ]}
> g = asShape(geo_if)
>
> which fails with:
> ValueError: Unknown geometry type: geometrycollection
>
>
> How can I create a GeometryCollection?
>
>
>
> --
> Best Regards,
>
> Christian Ledermann
>
> Nairobi - Kenya
> Mobile : +254 702978914
>
> <*)))>{
>
> If you save the living environment, the biodiversity that we have left,
> you will also automatically save the physical environment, too. But If
> you only save the physical environment, you will ultimately lose both.
>
> 1) Don’t drive species to extinction
>
> 2) Don’t destroy a habitat that species rely on.
>
> 3) Don’t change the climate in ways that will result in the above.
>
> }<(((*>
>
--
Best Regards,
Christian Ledermann
Nairobi - Kenya
Mobile : +254 702978914
<*)))>{
If you save the living environment, the biodiversity that we have left,
you will also automatically save the physical environment, too. But If
you only save the physical environment, you will ultimately lose both.
1) Don’t drive species to extinction
2) Don’t destroy a habitat that species rely on.
3) Don’t change the climate in ways that will result in the above.
}<(((*>
_______________________________________________
Community mailing list
[email protected]
http://lists.gispython.org/mailman/listinfo/community