資源簡介
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?????????????????{
????????????????????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個文件信息
評論
共有 條評論