Hi All,
We are using ArcGIS Pro SDK 2.7. We want to add a vertex/point to the polygon. We have tried multiple ways to achieve this.
1. a. Read existing polygon points into List .
b. Add the desired points (needs to add into polygon) to the list
c. Update the geometry with latest geometry.
Snippet;
var selectedTargetFeatures = ArcGIS.Desktop.Mapping.MapView.Active.Map.GetSelection();
var inspTargetInspector = new Inspector();
inspTargetInspector.Load(selectedTargetFeatures.Keys.First(), targetID);
Polygon objTargetPolygon = inspTargetInspector.Shape as Polygon;
ReadOnlyPointCollection objTargetPolyPointCollection = objTargetPolygon.Points;
ICollection<MapPoint> objMapPoints = new List<MapPoint>(objTargetPolyPointCollection.Count);
objTargetPolyPointCollection.CopyPointsToList(0, objTargetPolyPointCollection.Count - 1, ref objMapPoints);
objMapPoints.Add(resultMultipoint1.Points[0]);
objMapPoints.Add(resultMultipoint2.Points[0]);
Polygon polygon = PolygonBuilder.CreatePolygon(objMapPoints, SpatialReferences.WGS84);
inspTargetInspector.Shape = polygon;
//create and execute the edit operation
var op = new EditOperation()
{
Name = "Add vertex",
SelectModifiedFeatures = false,
SelectNewFeatures = false
};
op.Modify(inspTargetInspector);
op.Execute();
But here Problem is - all these new points are creating under new Part. We want all these points into existing polygon part.
2. We tried to follow runtime sdk approach.
a. Create PolygonBuilder object
b. Tried to read Part, Point index in ProximityResult , AddPoint in particular index -- We dont have access to these functionality in Pro SDK.
Code Snippet:
PolygonBuilder builder = new PolygonBuilder(objTargetPolygon); // Create builder from existing polygon
builder.Parts[0].InsertPoint(index, new MapPoint(x, y)); // Insert point into specific location
graphic.Geometry = builder.ToGeometry(); // Create geometry and assign it back to the graphic / feature
https://community.esri.com/t5/arcgis-runtime-sdk-for-net/command-addvertex/td-p/758557
----------------
Can someone please help us - how can we add vertex/point into existing polygon.
Also, @Wolf @UmaHarano - is there any plans to make it available all these functionalities in ArcGIS Pro SDK.
Solved! Go to Solution.
Hello,
Have you tried the
GeometryEngine.Instance.SplitAtPoint function?
https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/#topic27292.html
In your scenario the projectOnto and createPart parameters should be false.
Narelle
Hello,
Have you tried the
GeometryEngine.Instance.SplitAtPoint function?
https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/#topic27292.html
In your scenario the projectOnto and createPart parameters should be false.
Narelle
Thank you Narelle. This helped me. Thanks a lot.