arcgis pro 二次开发——获取图形中心点坐标

List list2D = new List();
list2D.Add(new Coordinate2D(0, 0));
list2D.Add(new Coordinate2D(0, 2));
list2D.Add(new Coordinate2D(2, 2));
list2D.Add(new Coordinate2D(2, 0));

Polygon polygon = PolygonBuilder.CreatePolygon(list2D, SpatialReferences.WGS84);

// verify it is simple
bool isSimple = GeometryEngine.Instance.IsSimpleAsFeature(polygon);
// find the centroid
MapPoint centroid = GeometryEngine.Instance.Centroid(polygon);
// centroid.X = 1
// centroid.Y = 1

// map Point
MapPoint pt1 = MapPointBuilder.CreateMapPoint(1, 2, 3, 4, SpatialReferences.WGS84);
MapPoint pt2 = MapPointBuilder.CreateMapPoint(5, 2, double.NaN, 7);

// pt1.HasZ = true
// pt1.HasM = true
centroid = GeometryEngine.Instance.Centroid(pt1);
// centroid.HasZ = true
// centroid.HasM = true
// pt1.IsEqual(centroid) = true

// multipoint
List list = new List() { pt1, pt2 };
Multipoint multipoint = MultipointBuilder.CreateMultipoint(list);
// multipoint.HasZ = true
// multipoint.HasM = true

centroid = GeometryEngine.Instance.Centroid(multipoint);
// centroid.X = 3
// centroid.Y = 2
// centroid.HasZ = false
// centroid.HasM = false

你可能感兴趣的:(arcgis,pro,扩展开发,c#,visualstudio)