陌生的不再陌生

导航

Dotspatial 创建面状图层

 

using DotSpatial.Controls;
using DotSpatial.Data;
using DotSpatial.Data.Forms;
using DotSpatial.Plugins.Measure;
using DotSpatial.Symbology;
using DotSpatial.Topology;
using DotSpatial.Topology.Algorithm;
using Point = DotSpatial.Topology.Point;
using PointShape = DotSpatial.Symbology.PointShape;

 

Shapefile s = new Shapefile();

//面状要素
FeatureSet fs = new FeatureSet(FeatureType.Polygon);

//增加字段
fs.DataTable.Columns.Add(new DataColumn("ID", typeof (int)));
fs.DataTable.Columns.Add(new DataColumn("Text", typeof (string)));

//坐标列表
List<Coordinate> vertices = new List<Coordinate>();
vertices.Add(new Coordinate(0, 0));
vertices.Add(new Coordinate(0, 100));
vertices.Add(new Coordinate(100, 100));
vertices.Add(new Coordinate(100, 0));

 

//创建多边形要素

Polygon geom = new Polygon(vertices);
IFeature feature = fs.AddFeature(geom);
feature.DataRow.BeginEdit();
feature.DataRow["ID"] = 1;
feature.DataRow["Text"] = "Hello world";
feature.DataRow.EndEdit();

//存储
fs.SaveAs("d:\\test.shp", true);

posted on 2016-01-11 20:50  陌生的不再陌生  阅读(1448)  评论(3编辑  收藏  举报