[gdal-dev] Adding multipolygons to an existing geometry collection
danotchki
danotchki at gmail.com
Wed Mar 24 12:11:42 EDT 2010
Hello List,
I hope you will be able to help me. I'm stuck on a problem.
I'm trying to reconstruct within my Python script polygons from a shapefile
that belong together.
So I naturally perfomed:
geom_tmp = ogr.CreateGeometryFromWkb(ftr.GetGeometryRef().ExportToWkb())
geom.AddGeometryDirectly(geom_tmp)
However this works only when the geometry to add is of type POLYGON. This
_doesn't_ work with type MULTIPOLYGON (exit code 3).
My question: is there a way to add MULTIPOLYGONs to an existing Geometry?
What I don't understand is that when CreateGeometryFromWkb returns a
MULTIPOLYGON it actually returns a GEOMETRY instead of a GEOMETRYCOLLECTION,
thus preventing looping on each individual geometry with GetNumGeometries.
Would there be a way to cast the polygon to a multipolygon?
Help very much appreciated.
Many thanks,
Daniel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20100324/07008fe0/attachment.html
More information about the gdal-dev
mailing list