C# arcgis新建polygon
时间: 2024-02-03 08:08:44 浏览: 137
以下是使用C# ArcGIS新建Polygon的示例代码:
```csharp
// 创建一个新的Polygon对象
IPolygon polygon = new PolygonClass();
// 创建一个点集合
IPointCollection pointCollection = polygon as IPointCollection;
// 添加点到集合中
IPoint point1 = new PointClass();
point1.PutCoords(0, 0);
pointCollection.AddPoint(point1);
IPoint point2 = new PointClass();
point2.PutCoords(0, 10);
pointCollection.AddPoint(point2);
IPoint point3 = new PointClass();
point3.PutCoords(10, 10);
pointCollection.AddPoint(point3);
IPoint point4 = new PointClass();
point4.PutCoords(10, 0);
pointCollection.AddPoint(point4);
// 设置填充样式
ISimpleFillSymbol simpleFillSymbol = new SimpleFillSymbolClass();
simpleFillSymbol.Style = esriSimpleFillStyle.esriSFSDiagonalCross;
// 创建一个新的Polygon元素
IFillShapeElement fillShapeElement = new PolygonElementClass();
fillShapeElement.Symbol = simpleFillSymbol;
fillShapeElement.Shape = polygon;
// 将元素添加到地图中
IMap map = axMapControl1.Map;
IElement element = fillShapeElement as IElement;
map.AddElement(element, 0);
// 刷新地图
axMapControl1.Refresh();
```
阅读全文