使用GDAL创建多边形、多部件要素、相邻面合并、以及shape文件创建的完整过程
1. 创建一个多边形
多边形必须闭合
// 创建第一个多边形几何对象Geometry polygon1 = new Geometry(wkbGeometryType.wkbPolygon);Geometry ring1 = new Geometry(wkbGeometryType.wkbLinearRing);ring1.AddPoint(0, 0);ring1.AddPoint(10, 0);ring1.AddPoint(10, 10);ring1.AddPoint(0, 10);ring1.AddPoint(0, 0); // 必须闭合polygon1.AddGeometry(ring1);
2. 创建多部件要素
Geometry multiPolygon = new Geometry(wkbGeometryType.wkbMultiPolygon);Dictionary<int, Geometry> polyDict = new Dictionary<int, Geometry>();polyDict[1] = polygon1;polyDict[2] = polygon2;// 将合并后的多边形添加到多部分几何图形中foreach (var entry in polyDict){multiPolygon.AddGeometry(entry.Value);}