当前位置:网站首页>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();
}
}边栏推荐
猜你喜欢
随机推荐
实时目标检测新高地之#YOLOv7#更快更强的目标检测器
依赖注入(DI),自动配置,集合注入
神经网络原理及代码实现
差分(前缀和的逆运算)
Roson的Qt之旅#104 QML Image控件
STL - string
C语言入门实战(14):选择排序
一文搞懂什么是@Component和@Bean注解以及如何使用
【OpenCV】 - 显示图像API之imshow()对不同位深度(数据类型)的图像的处理方法
Haisi project summary
Karatsuba大数乘法的Verilog实现
线程基础(二)
mysql系统变量与状态变量
excel高级绘图技巧100讲(二十一)- Excel层叠柱形图
《21天精通TypeScript-5》类型注解与原始类型
LiveData 记录下 +
LeetCode 264:丑数
在线开启gtid偶发hang住的问题解决
HCIP笔记整理 2022/7/20
VR全景市场拓展技巧之“拓客宝典”









