The data is in 'GCS_WGS_1984' and creating union polygon using IToplogicalOperator2.ConstructUnion successfully in different type of codes but in both cases found union polygon shift.
//Case-1
while ((feature = featureCursor.NextFeature()) != null)
{
ITopologicalOperator2 shape = feature.ShapeCopy as ITopologicalOperator2;
shape.IsKnownSimple_2 = false;
shape.Simplify();geometriesToUnion.AddGeometry(shape as IGeometry, ref missing, ref missing);
}
IGeoDataset geoDataset = ipTargetFeatureClass.FeatureDataset as IGeoDataset;IPolygon UnionPolygon = new PolygonClass();
UnionPolygon.SpatialReference = geoDataset.SpatialReference;
ITopologicalOperator2 topologicalOperator;
topologicalOperator = UnionPolygon as ITopologicalOperator2;topologicalOperator.ConstructUnion(geometriesToUnion as IEnumGeometry);
//Case-2
while ((feature = featureCursor.NextFeature()) != null)
{
ITopologicalOperator2 shape = feature.ShapeCopy as ITopologicalOperator2;
shape.IsKnownSimple_2 = false;
shape.Simplify();geometriesToUnion.AddGeometry(shape as IGeometry);
}ITopologicalOperator2 topologicalOperator = new PolygonClass();
topologicalOperator.ConstructUnion(geometriesToUnion as IEnumGeometry); // union all features
Please suggest if anything missing in the code
Solved! Go to Solution.
The issue is solved by setting spatial reference to GeometryBag
Snippet
IGeometryBag geoBag = new GeometryBagClass(); geoBag.SpatialReference = geoDataset.SpatialReference; IGeometryCollection geometriesToUnion = geoBag as IGeometryCollection;
The issue is solved by setting spatial reference to GeometryBag
Snippet
IGeometryBag geoBag = new GeometryBagClass(); geoBag.SpatialReference = geoDataset.SpatialReference; IGeometryCollection geometriesToUnion = geoBag as IGeometryCollection;