Dear List, I need to generate a multipolygon by adding all the polygons in a shapefile. Based on a previous post I plan to use the addgeometry() to pass each feature to the multipolygon layer. I have implemented this in python but I cannot figure out what is going wrong. Python says "'Geometry' object has no attribute 'addGeometry'" that i can understand but not really know how to fix. Below is the code, I would appreciate any help.
import ogr, os, sys driver=ogr.GetDriverByName('ESRI Shapefile') #open shape shapefileName= 'c:\\test_multi\\polygonize_binary.shp' dataset=driver.Open(shapefileName,0) fn = 'c:\\test_multi\\multi_out.shp' if os.path.exists(fn): driver.DeleteDataSource(fn) outDS = driver.CreateDataSource(fn) if outDS is None: print 'Could not create file' sys.exit(1) #Create a layer to receive the multiple geometry #create a layer outLayer = outDS.CreateLayer('multi_out', geom_type=ogr.wkbMultiPolygon) # create new id and fields in the output shapefile #add a new feature # create an empty multipolygon geometry m_poly = ogr.Geometry(ogr.wkbMultiPolygon) layer=dataset.GetLayer() for index in xrange(layer.GetFeatureCount()): feature = layer.GetFeature(index) geometry = feature.GetGeometryRef() #print geometry m_poly.addGeometry(geometry) -- View this message in context: http://osgeo-org.1560.n6.nabble.com/generating-multipolygon-from-polygons-tp4992794.html Sent from the GDAL - Dev mailing list archive at Nabble.com. _______________________________________________ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev