danotchki wrote:
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).

Daniel,

What type is "geom"?  If it is a MULTIPOLYGON then it can only
have polygons as children, not multipolygons.

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?

In C/C++ there are methods on OGRGeometryFactory like
forceToPolygon and forceToMultiPolygon that might be helpful
but I see these are not exposed in Python.  Are you willing to
build from SVN trunk source code?  If so, I could add these methods
for you.

Best regards,
--
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmer...@pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent

_______________________________________________
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev

Reply via email to