当前位置:网站首页>ArcEngine(八)用IWorkspaceFactory加载矢量数据
ArcEngine(八)用IWorkspaceFactory加载矢量数据
2022-08-03 07:28:00 【稻田里展望者】
private void iWorkSpaceToolStripMenuItem_Click(object sender, EventArgs e)
{
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Title = "加载shapefile数据";//设置title
openFileDialog.Filter = "(*.shp)|*.shp";//设置过滤模式
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
//设置路径
string fullPath = openFileDialog.FileName;//全部路径
string path = fullPath.Substring(0, fullPath.LastIndexOf("\\"));//截取字符串:除了名称之前的数据
string name = fullPath.Substring(fullPath.LastIndexOf("\\") + 1);//一直截取到末尾
}
IWorkspaceFactory workspaceFactory = new ShapefileWorkspaceFactoryClass();
IFeatureWorkspace featureworkspace = workspaceFactory.OpenFromFile(path, 0) as IFeatureWorkspace;
IFeatureLayer featurelayer = new FeatureLayerClass();
featurelayer.FeatureClass = featureworkspace.OpenFeatureClass(name);
featurelayer.Name = featurelayer.FeatureClass.AliasName;
if (MessageBox.Show("要素类已打开,名称为"+featurelayer.Name+",是否加载进地图?","提示",MessageBoxButtons.OKCancel,MessageBoxIcon.Question)==DialogResult.OK)
{
MapControl.AddLayer(featurelayer);
MapControl.Refresh();
}
}
边栏推荐
猜你喜欢
随机推荐
information_schema
boot - SSE
postman将接口返回结果生成csv文件到本地
924. 尽量减少恶意软件的传播 前缀和
postman将接口返回结果生成json文件到本地
The use of the database table structure document generation tool screw
CDGA|如何加强数字政府建设?
2022年 SQL 优化大全总结详解
最佳高质量字体
伦敦银现货市场如何使用多条均线?
pyspark df secondary sorting
pt-online-schema-change工具使用的一次
2022下半年软考「高项&集成」复习计划ta来喽~
[Hello World] 二分查找笔记
JS作用对象API技巧
- display image API OpenCV 】 【 imshow () to a depth (data type) at different image processing methods
@Async注解的坑,小心
如何像用自来水一样使用数据库?|腾讯云数据库TDSQL-C
pyspark---low frequency feature processing
Oracle Rac Cluster File Directory Migration