求实现空间查询功能的C#代码,是关于ArcEngine的。 20
1个回答
展开全部
IWorkspaceFactory pWorkspaceFactory = new ShapefileWorkspaceFactoryClass();//打开shapefile工作空间
openFileDialog1.Filter = ("shapefile文件(*.shp)|*.shp");//文件过滤
openFileDialog1.InitialDirectory=@"C:\Program Files\ARCGIS\GIS-Data";//默认路径吧
openFileDialog1.Multiselect = false;//只能单选
DialogResult pDialogResult = openFileDialog1.ShowDialog();
if (pDialogResult != DialogResult.OK)
return;//如果没点击确认 ,返回
string pPath = openFileDialog1.FileName;//获得文件的路径
string pFloder = Path.GetDirectoryName(pPath);//得到文件所在的文件夹位置
string pFileName = Path.GetFileName(pPath);//得到文件名
IWorkspace pWorkspace = pWorkspaceFactory.OpenFromFile(pFloder, 0);//打开工作空间
IFeatureWorkspace pFeatureWokkspace = pWorkspace as IFeatureWorkspace;//转换工作空间为要素工作空间
IFeatureClass pFC = pFeatureWokkspace.OpenFeatureClass(pFileName);//打开要素类
IFeatureLayer pFLayer = new FeatureLayerClass();
pFLayer.FeatureClass = pFC;//设置图层的featureclass为上面打开的文件
pFLayer.Name = pFC.AliasName;//设置图层的名称
ILayer pLayer = pFLayer as ILayer;//转换featurelayer为layer
IMap pMap = axMapControl1.Map;
pMap.AddLayer(pLayer);//添加图层
axMapControl1.ActiveView.Refresh();//刷新
openFileDialog1.Filter = ("shapefile文件(*.shp)|*.shp");//文件过滤
openFileDialog1.InitialDirectory=@"C:\Program Files\ARCGIS\GIS-Data";//默认路径吧
openFileDialog1.Multiselect = false;//只能单选
DialogResult pDialogResult = openFileDialog1.ShowDialog();
if (pDialogResult != DialogResult.OK)
return;//如果没点击确认 ,返回
string pPath = openFileDialog1.FileName;//获得文件的路径
string pFloder = Path.GetDirectoryName(pPath);//得到文件所在的文件夹位置
string pFileName = Path.GetFileName(pPath);//得到文件名
IWorkspace pWorkspace = pWorkspaceFactory.OpenFromFile(pFloder, 0);//打开工作空间
IFeatureWorkspace pFeatureWokkspace = pWorkspace as IFeatureWorkspace;//转换工作空间为要素工作空间
IFeatureClass pFC = pFeatureWokkspace.OpenFeatureClass(pFileName);//打开要素类
IFeatureLayer pFLayer = new FeatureLayerClass();
pFLayer.FeatureClass = pFC;//设置图层的featureclass为上面打开的文件
pFLayer.Name = pFC.AliasName;//设置图层的名称
ILayer pLayer = pFLayer as ILayer;//转换featurelayer为layer
IMap pMap = axMapControl1.Map;
pMap.AddLayer(pLayer);//添加图层
axMapControl1.ActiveView.Refresh();//刷新
Storm代理
2023-07-25 广告
2023-07-25 广告
StormProxies是一家提供动态代理服务器服务的企业,旨在帮助用户更好地管理网络访问和安全。以下是一些关于StormProxies的IP动态代理服务的特点:1. 高匿名性:StormProxies的动态代理服务器具有高匿名性,可以有效...
点击进入详情页
本回答由Storm代理提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询