Union of buffer polygons - ConstructUnion

2372
1
11-29-2012 05:39 AM
JulianaCastillo
New Contributor
Hi all. I initially posted this under the ArcGIS Server General forum, but realized it would fit more in here.

I'm having issues when trying to combine multiple buffer polygon geometries into one while using the ConstructUnion method from the ITopologicalOperator2 class.
It does not give me an error, but the polygon I get, is not exactly the union of all other polygons.
I've attached an image of the polygon result geometry.

[ATTACH=CONFIG]19602[/ATTACH]

Here is the code I'm using.

for (int geomIdx = 0; geomIdx < bufferGeometryCollection.GeometryCount; geomIdx++)
                {

                    IGeometry currentGeom = bufferGeometryCollection.Geometry[geomIdx];
                    ISpatialReference geomSR = currentGeom.SpatialReference;

                    //if geometry is a point, convert to polygon
                    if (currentGeom.GeometryType == esriGeometryType.esriGeometryPoint)
                    {
                        IEnvelope pEnv = currentGeom.Envelope;
                        pEnv.Expand(0.0001, 0.0001, false);
                        IPolygon pPoly = new PolygonClass();
                        ISegmentCollection pSegCol = (ISegmentCollection)pPoly;
                        pSegCol.SetRectangle(pEnv);
                        currentGeom = (IGeometry)pSegCol;
                    }


                    //Create an ITopologicalOperator object based upon a geometry
                    ITopologicalOperator topoOp = (ITopologicalOperator)currentGeom;
                    //'Generate the buffer
                    IPolygon bufferPolygon = (IPolygon)topoOp.Buffer(bufferDistance);

                    topoOp2 = (ITopologicalOperator2)bufferPolygon;
                    topoOp2.IsKnownSimple_2 = false;
                    topoOp2.Simplify();

                    geometryCollection.AddGeometry(topoOp2 as IGeometry, ref missing, ref missing);

                }

                IPolygon poly = new PolygonClass();
                poly.SpatialReference = _outputSpatialReference;

                ITopologicalOperator2 topologicalOperator;
                topologicalOperator = poly as ITopologicalOperator2;

                topologicalOperator.ConstructUnion(geometryCollection as IEnumGeometry);

                return topologicalOperator as IPolygon;


I'm following ESRI samples, and this is the result, which does not work.
I've tried without the simplify and it gives me the same result.
I've also tried to create the polygon by adding the rings separately with the same result.

What am I missing?

Thanks!

Juliana
0 Kudos
1 Reply
JulianaCastillo
New Contributor
Hi all. I initially posted this under the ArcGIS Server General forum, but realized it would fit more in here.

I'm having issues when trying to combine multiple buffer polygon geometries into one while using the ConstructUnion method from the ITopologicalOperator2 class.
It does not give me an error, but the polygon I get, is not exactly the union of all other polygons.
I've attached an image of the polygon result geometry.

[ATTACH=CONFIG]19602[/ATTACH]

Here is the code I'm using.

for (int geomIdx = 0; geomIdx < bufferGeometryCollection.GeometryCount; geomIdx++)
                {

                    IGeometry currentGeom = bufferGeometryCollection.Geometry[geomIdx];
                    ISpatialReference geomSR = currentGeom.SpatialReference;

                    //if geometry is a point, convert to polygon
                    if (currentGeom.GeometryType == esriGeometryType.esriGeometryPoint)
                    {
                        IEnvelope pEnv = currentGeom.Envelope;
                        pEnv.Expand(0.0001, 0.0001, false);
                        IPolygon pPoly = new PolygonClass();
                        ISegmentCollection pSegCol = (ISegmentCollection)pPoly;
                        pSegCol.SetRectangle(pEnv);
                        currentGeom = (IGeometry)pSegCol;
                    }


                    //Create an ITopologicalOperator object based upon a geometry
                    ITopologicalOperator topoOp = (ITopologicalOperator)currentGeom;
                    //'Generate the buffer
                    IPolygon bufferPolygon = (IPolygon)topoOp.Buffer(bufferDistance);

                    topoOp2 = (ITopologicalOperator2)bufferPolygon;
                    topoOp2.IsKnownSimple_2 = false;
                    topoOp2.Simplify();

                    geometryCollection.AddGeometry(topoOp2 as IGeometry, ref missing, ref missing);

                }

                IPolygon poly = new PolygonClass();
                poly.SpatialReference = _outputSpatialReference;

                ITopologicalOperator2 topologicalOperator;
                topologicalOperator = poly as ITopologicalOperator2;

                topologicalOperator.ConstructUnion(geometryCollection as IEnumGeometry);

                return topologicalOperator as IPolygon;


I'm following ESRI samples, and this is the result, which does not work.
I've tried without the simplify and it gives me the same result.
I've also tried to create the polygon by adding the rings separately with the same result.

What am I missing?

Thanks!

Juliana


After some additional research, I found out that the code above works just fine when I want to union polygons that overlap.
With excluding buffer polygon features, the buffer gets messed up while using the ConstructionUnion, or Union.
I'm now trying to create a multipart polygon adding the separate geometries as rings but get the same result.
When I review the ring, the ring is closed, but for some reason after adding multiple rings to the polygon, the geometry goes, from the ToPoint of one Ring to the FromPoint of the next ring.
Any ideas on how to keep the From and To points on each ring?

Thanks!

Juliana
0 Kudos