generalize or simplify complex polygons - for buffer and intersect

2400
1
06-26-2013 08:45 AM
tonydavid
New Contributor III
Hi, anyone had experience working with all these options to ???simplify??? or generalize complex polygons (pros and cons)??

1. IGeometryServer2 Generalize (can't find any sample code)
2. IPolygon Simplifyex and ITopologicalOperator Simplify

I want to loop polygons in a feature class, convert these complex polygon (with lotsa vertexes and bezier curves) to a simplified version and then run some simple topo operations (buffer, intersect).

Main reason for doing this is ... even simple topo operations on these complex polygons takes way too long to complete. If you have other suggestions most welcome ...

Thanks.
0 Kudos
1 Reply
WeifengHe
Occasional Contributor II
When you say simplified version of polygons for performance reason, my understanding is you mean polygons with less vertices, not meaning topologically simple.

If my understanding is right, I'd suggest you use IGeometryServer2::Generalize if you want to process a bunch of polygons at one time.  If just few polygons involved, you can also consider IPolycurve::Generalize method.

I come up with a piece of .NET code to show how to use IGeometryServer2::Generalize.

            //Initiliaze some input parameters.  Suppose featClsInput is the feature class you are working on.
            ISpatialReference inSR= (featClsInput as IGeoDataset).SpatialReference;
            IGeometryArray arrayIn = new GeometryArrayClass(); //input array of geometries
            IFeatureCursor featCur = featClsInput.Search(null, true);
            IFeature feat;
            while ((feat = featCur.NextFeature()) != null)
            {
                arrayIn .Add(feat.ShapeCopy as IGeometry);
            }
            double md = someValue; //max deviation
            ISpatialReferenceFactory srf = new SpatialReferenceEnvironmentClass();
            ILinearUnit u = srf.CreateUnit((int)esriSRUnitType.esriSRUnit_Meter) as ILinearUnit;

            IGeometryServer2 geomSrv2 = new GeometryServerImplClass();
            IGeometryArray arrayOut = geomSrv2.Generalize(inSR, arrayIn, md, u);

You can retrieve the output polygons by calling arrayOut.get_Element(index)

Hope it helps.
0 Kudos