《C# ArcEngine 添加打开Shp矢量数据》由会员分享,可在线阅读,更多相关《C# ArcEngine 添加打开Shp矢量数据(2页珍藏版)》请在金锄头文库上搜索。
1、using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using ESRI.ArcGIS.Carto;using ESRI.ArcGIS.DataSourcesFile;using ESRI.ArcGIS.Geodatabase;private void 打开矢量数据ToolStripMenuItem
2、_Click(object sender, EventArgs e) OpenFileDialog file = new OpenFileDialog(); file.Filter = Shp文件|*.shp; if ( file.ShowDialog() = DialogResult.OK ) string path = file.FileName; string folder = System.IO.Path.GetDirectoryName(path); string filename = System.IO.Path.GetFileName(path); IWorkspaceFacto
3、ry wsf = new ShapefileWorkspaceFactory(); IWorkspace ws = wsf.OpenFromFile(folder,0); IFeatureWorkspace fws = ws as IFeatureWorkspace; IFeatureClass fc = fws.OpenFeatureClass(filename); IFeatureLayer fl = new FeatureLayer(); fl.FeatureClass = fc; fl.Name = fc.AliasName; axMapControl1.AddLayer(fl); axMapControl1.ActiveView.Refresh(); else return;