Center point of polygon

3473
1
Jump to solution
08-24-2015 05:49 AM
mikeharol1
New Contributor II

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

Thanks

Mike

0 Kudos
1 Solution

Accepted Solutions
by Anonymous User
Not applicable

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
by Anonymous User
Not applicable

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);
      });
    }