zoukankan      html  css  js  c++  java
  • AE 打开Shp文件

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using System.IO;
    using ESRI.ArcGIS.Carto;
    using ESRI.ArcGIS.DataSourcesFile;
    using ESRI.ArcGIS.Geodatabase;
     
    namespace addshp
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
     
            private void menuAddshpToolStripMenuItem_Click(object sender, EventArgs e)
            {//menuestrip.click
               
     
                OpenFileDialog opfd1 = new OpenFileDialog();
                opfd1.Filter = "shapefile(*.shp)|*.shp|allfile(*.*)|*.*";
                opfd1.Multiselect = false;
                opfd1.InitialDirectory = @"F:	empNautical & FME 论文	empResult";
                DialogResult diaLres = opfd1.ShowDialog();           
                if (diaLres != DialogResult.OK)
                    return;                      
                string path1 = opfd1.FileName;
                //openfiledialog 常规使用
     
                string pFolder = Path.GetDirectoryName(path1);
                string pFileName = Path.GetFileName(path1);
                //System.IO.Path
     
                IWorkspaceFactory pworkspaceFactory = new ShapefileWorkspaceFactory();
                //创建工作空间工厂
                
               IWorkspace pWorkspace= pworkspaceFactory.OpenFromFile(pFolder, 0);
                //打开shpfile工作空间
     
               IFeatureWorkspace pFeatureWorkspace = pWorkspace as IFeatureWorkspace;
               IFeatureClass pFC = pFeatureWorkspace.OpenFeatureClass(pFileName);
                //打开要素类 
     
               IFeatureLayer pFLayer = new FeatureLayerClass();
                //创建要素图层
     
               pFLayer.FeatureClass = pFC;
               pFLayer.Name = pFC.AliasName;
               ILayer pLayer = pFLayer as ILayer;
                //以上三行:关联图层和要素类
     
               IMap pmap = axMapControl1.Map;
               pmap.AddLayer(pLayer);
               axMapControl1.ActiveView.Refresh();           
            }
     
            private void menuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
            {
                //NULL
            }
     
            private void propertiesToolStripMenuItem_Click(object sender, EventArgs e)
            {
                Form2 fm = new Form2(axMapControl1);
                fm.ShowDialog();
            }
        }
    }

    转载于AE入门基础教程,示例

  • 相关阅读:
    什么是method swizzling
    手机安全卫士——手机防盗页面
    手机安全卫士——在设置中心 自定义view和自定义属性
    手机安全卫士——主界面的开发
    手机安全卫士——闪屏页相关处理
    Android开发学习——自定义View
    C#开发学习——SqlHelper的应用
    基本的SQL语句
    C#开发学习——常用的正则表达式
    C#开发学习——存储过程
  • 原文地址:https://www.cnblogs.com/wodewei/p/11593235.html
Copyright © 2011-2022 走看看