当前位置:网站首页>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();
}
}边栏推荐
猜你喜欢
随机推荐
STL迭代器
How to choose a reliable and formal training institution for the exam in September?
“唯一索引允许为空“ 的说法是不严谨的
推荐系统-排序层-特征工程:用户特征、物品特征
Shell脚本之一键安装mysql
Neo4j 4.X:导入OWL文件
Postman will return to the interface to generate a json file to the local
001-进程与线程
ORB-SLAM2提取特征点
tolower函数
pyspark---low frequency feature processing
第一章:ARM公司Cortex-M 系列处理器介绍,第二章:嵌入式软件开发介绍和第三章:Cortex-M3和Cortex-M4处理器的一般介绍
Taro框架-微信小程序-内嵌h5页面
consul理解
redis AOF持久化个人理解
升级
2022下半年软考「高项&集成」复习计划ta来喽~
PMP每日一练 | 考试不迷路-8.2(包含敏捷+多选)
volta管理node版本
加速FinOps实践,为企业降本增效








