• 大小: 72KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-16
  • 语言: C#
  • 标签: C#  ArcEngine  矢量  栅格  

资源简介

C#+ArcEngine:shp矢量点转栅格(VS2010窗体+代码)。

资源截图

代码片段和文件信息

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.SystemUI;
using ESRI.ArcGIS.Geodatabase;
using ESRI.ArcGIS.DataSourcesFile;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.GeoAnalyst;
using ESRI.ArcGIS.DataSourcesRaster;

namespace ShpPointToRaster
{
    public partial class MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();
        }

        //Shp点路径
        private void btnShp_Click(object sender EventArgs e)
        {
            //打开shp
            this.axMapControl1.Clearlayers();//先清空当前
            OpenFileDialog xjShpOpenFileDialog = new OpenFileDialog();
            xjShpOpenFileDialog.title = “打开矢量数据“;
            xjShpOpenFileDialog.Filter = “矢量文件(*.shp)|*.shp“;
            if (xjShpOpenFileDialog.ShowDialog() == DialogResult.OK)
            {
                string ShpFullPath = xjShpOpenFileDialog.FileName;
                string ShpFolder = System.IO.Path.GetDirectoryName(ShpFullPath);
                string ShpFileName = System.IO.Path.GetFileName(ShpFullPath);
                this.txtShp.Text = ShpFullPath;
                //工作工厂+工作空间
                IWorkspaceFactory ShpWsF = new ShapefileWorkspaceFactory();//using Geodatabase + DataSourcesFile
                IWorkspace ShpWs = ShpWsF.OpenFromFile(ShpFolder 0);

                //IFeatureWorkspace ShpFWs = (IFeatureWorkspace)ShpWsF.OpenFromFile(ShpFolder 0);
                IFeatureWorkspace ShpFWs = (IFeatureWorkspace)ShpWs;
                IFeatureClass ShpFeatureClass = ShpFWs.OpenFeatureClass(ShpFileName);

                IFeaturelayer ShpFeaturelayer = new Featurelayer();//引用Carto
                ShpFeaturelayer.FeatureClass = ShpFeatureClass;
                ShpFeaturelayer.Name = ShpFeatureClass.AliasName;

                //加载刷新
                this.axMapControl1.Addlayer(ShpFeaturelayer);
                this.axMapControl1.ActiveView.Refresh();

                //字段
                this.cmbField.Items.Clear();//清空选项
                int FieldCount = ShpFeatureClass.Fields.FieldCount;
                for (int i = 0; i < FieldCount; i++)
                {
                    this.cmbField.Items.Add(ShpFeatureClass.Fields.get_Field(i).Name);
                }
            }
        }

        //设置输出栅格路径
        private void btnRaster_Click(object sender EventArgs e)
        {
            SaveFileDialog xjRasterSaveFileDialog = new SaveFileDialog();
            xjRasterSaveFileDialog.Filter = “栅格文件(*.tiff)|*.tiff“;
            if (xjRasterSaveFileDialog.ShowDialog() == DialogResult.OK)
            {
                this.txtRaster.Text = xjRasterSaveFileDialog.FileName;
            }
        }

        //转换
        private void btnTransform_Click(object sender EventArgs e)
        {
            string xjShp

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件        760  2018-05-07 21:54  ShpPointToRaster\ShpPointToRaster\bin\Debug\info\arc.dir

     文件      19968  2018-05-07 21:59  ShpPointToRaster\ShpPointToRaster\bin\Debug\ShpPointToRaster.exe

     文件      28160  2018-05-07 21:59  ShpPointToRaster\ShpPointToRaster\bin\Debug\ShpPointToRaster.pdb

     文件      11600  2018-05-07 21:59  ShpPointToRaster\ShpPointToRaster\bin\Debug\ShpPointToRaster.vshost.exe

     文件        490  2015-07-10 19:01  ShpPointToRaster\ShpPointToRaster\bin\Debug\ShpPointToRaster.vshost.exe.manifest

     文件       5264  2018-05-07 21:59  ShpPointToRaster\ShpPointToRaster\MainForm.cs

     文件       9869  2018-05-03 22:23  ShpPointToRaster\ShpPointToRaster\MainForm.Designer.cs

     文件       9950  2018-05-03 22:23  ShpPointToRaster\ShpPointToRaster\MainForm.resx

     文件     126808  2018-05-02 22:30  ShpPointToRaster\ShpPointToRaster\obj\x86\Debug\DesignTimeResolveAssemblyReferences.cache

     文件       7561  2018-05-07 21:59  ShpPointToRaster\ShpPointToRaster\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件       1069  2018-05-07 21:59  ShpPointToRaster\ShpPointToRaster\obj\x86\Debug\ShpPointToRaster.csproj.FileListAbsolute.txt

     文件        978  2018-05-03 22:27  ShpPointToRaster\ShpPointToRaster\obj\x86\Debug\ShpPointToRaster.csproj.GenerateResource.Cache

     文件      88456  2018-05-03 22:13  ShpPointToRaster\ShpPointToRaster\obj\x86\Debug\ShpPointToRaster.csprojResolveAssemblyReference.cache

     文件      19968  2018-05-07 21:59  ShpPointToRaster\ShpPointToRaster\obj\x86\Debug\ShpPointToRaster.exe

     文件       2874  2018-05-03 22:27  ShpPointToRaster\ShpPointToRaster\obj\x86\Debug\ShpPointToRaster.MainForm.resources

     文件      28160  2018-05-07 21:59  ShpPointToRaster\ShpPointToRaster\obj\x86\Debug\ShpPointToRaster.pdb

     文件        180  2018-05-03 22:27  ShpPointToRaster\ShpPointToRaster\obj\x86\Debug\ShpPointToRaster.Properties.Resources.resources

     文件        591  2018-05-02 22:25  ShpPointToRaster\ShpPointToRaster\Program.cs

     文件       1364  2018-05-02 22:18  ShpPointToRaster\ShpPointToRaster\Properties\AssemblyInfo.cs

     文件       2884  2018-05-02 22:18  ShpPointToRaster\ShpPointToRaster\Properties\Resources.Designer.cs

     文件       5612  2018-05-02 22:18  ShpPointToRaster\ShpPointToRaster\Properties\Resources.resx

     文件       1103  2018-05-02 22:18  ShpPointToRaster\ShpPointToRaster\Properties\Settings.Designer.cs

     文件        249  2018-05-02 22:18  ShpPointToRaster\ShpPointToRaster\Properties\Settings.settings

     文件       6679  2018-05-03 22:27  ShpPointToRaster\ShpPointToRaster\ShpPointToRaster.csproj

     文件        890  2018-05-02 22:18  ShpPointToRaster\ShpPointToRaster.sln

    ..A..H.     27648  2018-05-07 22:00  ShpPointToRaster\ShpPointToRaster.suo

     目录          0  2018-05-02 22:18  ShpPointToRaster\ShpPointToRaster\obj\x86\Debug\TempPE

     目录          0  2018-05-07 21:54  ShpPointToRaster\ShpPointToRaster\bin\Debug\info

     目录          0  2018-05-07 21:59  ShpPointToRaster\ShpPointToRaster\obj\x86\Debug

     目录          0  2018-05-07 21:54  ShpPointToRaster\ShpPointToRaster\bin\Debug

............此处省略10个文件信息

评论

共有 条评论