Center point of polygon

2710
1
Jump to solution
08-24-2015 05:49 AM
Highlighted
New Contributor

I would like to know a good way to  return the center point of  a  polygon with the arcgispro sdk.

Thanks

Mike

Reply
0 Kudos
1 Solution

Accepted Solutions
Highlighted
Esri Regular Contributor

Mike,

The labelpoint method on the GeometryEngine class should do it.

The following code will find the labelpoint for the first selected feature.

    protected override void OnClick()
    {
      //Run on MCT
      ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
      {
        //get the labelpoint for the first selected feature
        var selectedFeatures = ArcGIS.Desktop.Mapping.MapView.Active.Map.GetSelection();

        //load into editors inspector to get the shape geometry
        var insp = new ArcGIS.Desktop.Editing.Attributes.Inspector();
        insp.Load(selectedFeatures.First().Key, selectedFeatures.First().Value.First());
        var selGeom = insp.Shape;

        var labelPoint = ArcGIS.Core.Geometry.GeometryEngine.LabelPoint(selGeom);
      });
    }

View solution in original post

1 Reply
Highlighted
Esri Regular Contributor

Mike,

The labelpoint method on the GeometryEngine class should do it.

The following code will find the labelpoint for the first selected feature.

    protected override void OnClick()
    {
      //Run on MCT
      ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
      {
        //get the labelpoint for the first selected feature
        var selectedFeatures = ArcGIS.Desktop.Mapping.MapView.Active.Map.GetSelection();

        //load into editors inspector to get the shape geometry
        var insp = new ArcGIS.Desktop.Editing.Attributes.Inspector();
        insp.Load(selectedFeatures.First().Key, selectedFeatures.First().Value.First());
        var selGeom = insp.Shape;

        var labelPoint = ArcGIS.Core.Geometry.GeometryEngine.LabelPoint(selGeom);
      });
    }

View solution in original post