Good day,
I know there are several ways to find the center point of a polygon. One is Centroid (the one I have built)
The second option is MeanCenter (the one I have built).
Are there any more?
This is MeanCenter:
protected override async void OnClick()
{
var mapView = MapView.Active;
if (mapView != null)
{
await QueuedTask.Run(async () =>
{
var pathCenter = @"D:\MeanCenter.shp";
object[] listOfParame = { dissFeat };
await StartGp("stats.MeanCenter", listOfParame);
});
}
}
private static async Task StartGp(string funcArc, object[] parame)
{
var parameters = Geoprocessing.MakeValueArray(parame);
// FunctionPart(funcArc, parameters);
await Geoprocessing.ExecuteToolAsync(funcArc, parameters).ConfigureAwait(false);
}
Here is Centroid method:
protected override async void OnClick()
{
var mapView = MapView.Active;
if (mapView != null)
{
await QueuedTask.Run(async () =>
{
var featToPoly = @"D:\featToPoly.shp";
object[] paraList = { dissFeat, featToPoly };
await StartGp("management.FeatureToPolygon", paraList);
var featurePolyogn = MapView.Active.Map.FindLayers("featToPoly").First() as FeatureLayer;
var fc = featurePolyogn.GetTable() as FeatureClass;
using (var cursor = fc.Search())
{
while (cursor.MoveNext())
{
using (var feature = cursor.Current as Feature)
{
if (feature == null) continue;
Polygon polygon = feature.GetShape() as Polygon;
using (PolygonBuilder pb = new PolygonBuilder(polygon))
{
Polygon myPolygon = pb.ToGeometry();
await CreateFcWithAttributesAsync("Center_Point", EnumFeatureClassType.POINT);
var pointLayer = MapView.Active.Map.FindLayers("Center_Point").First() as FeatureLayer;
var mapPoint = GeometryEngine.Instance.Centroid(myPolygon);
var createOperation = new EditOperation();
createOperation.Create(pointLayer, mapPoint);
createOperation.Execute();
}
});
}
}
}
});
}
}
private static async Task StartGp(string funcArc, object[] parame)
{
var parameters = Geoprocessing.MakeValueArray(parame);
// FunctionPart(funcArc, parameters);
await Geoprocessing.ExecuteToolAsync(funcArc, parameters).ConfigureAwait(false);
}
Thank you all!