ArcEngine加载图层的五个步骤Word格式文档下载.docx

上传人:b****5 文档编号:21445311 上传时间:2023-01-30 格式:DOCX 页数:11 大小:16.84KB
下载 相关 举报
ArcEngine加载图层的五个步骤Word格式文档下载.docx_第1页
第1页 / 共11页
ArcEngine加载图层的五个步骤Word格式文档下载.docx_第2页
第2页 / 共11页
ArcEngine加载图层的五个步骤Word格式文档下载.docx_第3页
第3页 / 共11页
ArcEngine加载图层的五个步骤Word格式文档下载.docx_第4页
第4页 / 共11页
ArcEngine加载图层的五个步骤Word格式文档下载.docx_第5页
第5页 / 共11页
点击查看更多>>
下载资源
资源描述

ArcEngine加载图层的五个步骤Word格式文档下载.docx

《ArcEngine加载图层的五个步骤Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《ArcEngine加载图层的五个步骤Word格式文档下载.docx(11页珍藏版)》请在冰豆网上搜索。

ArcEngine加载图层的五个步骤Word格式文档下载.docx

//Addthefollowingreferencestotheproject:

//ESRI.ArcGIS.DataSourcesRaster

//ESRI.ArcGIS.Geodatabase

//ESRI.ArcGIS.System

//IntendedArcGISProductsforthissnippet:

//ArcGISDesktop(ArcEditor,ArcInfo,ArcView)

//ArcGISEngine

//ArcGISServer

//ApplicableArcGISProductVersions:

//9.2

//9.3

//RequiredArcGISExtensions:

//ArcGISSpatialAnalyst

//Notes:

//ThissnippetisintendedtobeinsertedatthebaselevelofaClass.

//ItisnotintendedtobenestedwithinanexistingMethod.

///<

summary>

///OpenaRasterfileondiskbyit'

/summary>

paramname="

path"

>

ASystem.Stringthatisthedirectorylocationoftherasterfile.Example:

"

C:

\raster_data"

<

/param>

name"

ASystem.Stringthatisthenameoftherasterfileinthedirectory.Example:

landuse"

or"

watershed"

returns>

AnIGeoDatasetinterface.<

/returns>

remarks>

///IRasterWorkspaceisusedtoaccessarasterstoredinafilesysteminanysupportedrasterformat.

///RasterWorkspaceFactorymustbeusedtocreatearasterworkspace.

///Toaccessrasterfromgeodatabase,useIRasterWorkspaceExinterface.

///

///FormoreinformationonworkingwiththeArcGISSpatialAnaylstobjectssee:

/remarks>

publicESRI.ArcGIS.Geodatabase.IGeoDatasetOpenRasterFileAsGeoDatset(System.Stringpath,System.Stringname)

{

try

{

ESRI.ArcGIS.Geodatabase.IWorkspaceFactoryworkspaceFactory=newESRI.ArcGIS.DataSourcesRaster.RasterWorkspaceFactoryClass();

ESRI.ArcGIS.DataSourcesRaster.IRasterWorkspacerasterWorkspace=(ESRI.ArcGIS.DataSourcesRaster.IRasterWorkspace)(workspaceFactory.OpenFromFile(path,0));

ESRI.ArcGIS.Geodatabase.IRasterDatasetrasterDataset=rasterWorkspace.OpenRasterDataset(name);

ESRI.ArcGIS.Geodatabase.IGeoDatasetgeoDataset=(ESRI.ArcGIS.Geodatabase.IGeoDataset)rasterDataset;

//ExplicitCast

returngeoDataset;

}

catch(Exceptionex)

//System.Diagnostics.Debug.WriteLine(ex.Message)

returnnull;

}

#endregion[VisualBasic.NET]

#Region"

'

ArcGISSnippetTitle:

OpenRasterFileAsGeoDatset

LongDescription:

OpenaRasterfileondiskbyit'

Addthefollowingreferencestotheproject:

ESRI.ArcGIS.DataSourcesRaster

ESRI.ArcGIS.Geodatabase

ESRI.ArcGIS.System

IntendedArcGISProductsforthissnippet:

ArcGISDesktop(ArcEditor,ArcInfo,ArcView)

ArcGISEngine

ArcGISServer

ApplicableArcGISProductVersions:

9.2

9.3

RequiredArcGISExtensions:

ArcGISSpatialAnalyst

Notes:

ThissnippetisintendedtobeinsertedatthebaselevelofaClass.

ItisnotintendedtobenestedwithinanexistingFunctionorSub.

<

IRasterWorkspaceisusedtoaccessarasterstoredinafilesysteminanysupportedrasterformat.

RasterWorkspaceFactorymustbeusedtocreatearasterworkspace.

Toaccessrasterfromgeodatabase,useIRasterWorkspaceExinterface.

FormoreinformationonworkingwiththeArcGISSpatialAnaylstobjectssee:

PublicFunctionOpenRasterFileAsGeoDatset(ByValpathAsSystem.String,ByValnameAsSystem.String)AsESRI.ArcGIS.Geodatabase.IGeoDataset

Try

DimworkspaceFactoryAsESRI.ArcGIS.Geodatabase.IWorkspaceFactory=NewESRI.ArcGIS.DataSourcesRaster.RasterWorkspaceFactoryClass()

DimrasterWorkspaceAsESRI.ArcGIS.DataSourcesRaster.IRasterWorkspace=CType(workspaceFactory.OpenFromFile(path,0),ESRI.ArcGIS.DataSourcesRaster.IRasterWorkspace)

DimrasterDatasetAsESRI.ArcGIS.Geodatabase.IRasterDataset=rasterWorkspace.OpenRasterDataset(name)

DimgeoDatasetAsESRI.ArcGIS.Geodatabase.IGeoDataset=CType(rasterDataset,ESRI.ArcGIS.Geodatabase.IGeoDataset)'

ExplicitCast

ReturngeoDataset

CatchexAsException

'

System.Diagnostics.Debug.WriteLine(ex.Message)

ReturnNothing

EndTry

EndFunction

#EndRegion

2.添加shapefile

AddShapefileUsingOpenFileDialog"

//AddShapefileUsingOpenFileDialog

//AddashapefiletotheActiveViewusingtheWindows.Forms.OpenFileDialogcontrol.

//ESRI.ArcGIS.Carto

//ESRI.ArcGIS.DataSourcesFile

//ESRI.ArcGIS.Display

//ESRI.ArcGIS.Geometry

//System.Windows.Forms

//(NONE)

///<

AddashapefiletotheActiveViewusingtheWindows.Forms.OpenFileDialogcontrol.<

///

activeView"

AnIActiveViewinterface<

publicvoidAddShapefileUsingOpenFileDialog(ESRI.ArcGIS.Carto.IActiveViewactiveView)

//parametercheck

if(activeView==null)

return;

//UsetheOpenFileDialogClasstochoosewhichshapefiletoload.

System.Windows.Forms.OpenFileDialogopenFileDialog=newSystem.Windows.Forms.OpenFileDialog();

openFileDialog.InitialDirectory="

c:

\\"

;

openFileDialog.Filter="

Shapefiles(*.shp)|*.shp"

openFileDialog.FilterIndex=2;

openFileDialog.RestoreDirectory=true;

openFileDialog.Multiselect=false;

if(openFileDialog.ShowDialog()==System.Windows.Forms.DialogResult.OK)

//Theuserchoseaparticularshapefile.

//Thereturnedstringwillbethefullpath,filenameandfile-extensionforthechosenshapefile.Example:

\test\cities.shp"

stringshapefileLocation=openFileDialog.FileName;

if(shapefileLocation!

="

"

//Ensuretheuserchoosesashapefile

//CreateanewShapefileWorkspaceFactoryCoClasstocreateanewworkspace

ESRI.ArcGIS.Geodatabase.IWorkspaceFactoryworkspaceFactory=newESRI.ArcGIS.DataSourcesFile.ShapefileWorkspaceFactoryClass();

//System.IO.Path.GetDirectoryName(shapefileLocation)returnsthedirectorypartofthestring.Example:

\test\"

ESRI.ArcGIS.Geodatabase.IFeatureWorkspacefeatureWorkspace=(ESRI.ArcGIS.Geodatabase.IFeatureWorkspace)workspaceFactory.OpenFromFile(System.IO.Path.GetDirectoryName(shapefileLocation),0);

//System.IO.Path.GetFileNameWithoutExtension(shapefileLocation)returnsthebasefilename(withoutextension).Example:

cities"

ESRI.ArcGIS.Geodatabase.IFeatureClassfeatureClass=featureWorkspace.OpenFeatureClass(System.IO.Path.GetFileNameWithoutExtension(shapefileLocation));

ESRI.ArcGIS.Carto.IFeatureLayerfeatureLayer=newESRI.ArcGIS.Carto.FeatureLayerClass();

featureLayer.FeatureClass=featureClass;

featureLayer.Name=featureClass.AliasName;

featureLayer.Visible=true;

activeView.FocusMap.AddLayer(featureLayer);

//Zoomthedisplaytothefullextentofalllayersinthemap

activeView.Extent=activeView.FullExtent;

activeView.PartialRefresh(ESRI.ArcGIS.Carto.esriViewDrawPhase.esriViewGeography,null,null);

else

//Theuserdidnotchooseashapefile.

//Dowhateverremedialactionsasnecessary

//System.Windows.Forms.MessageBox.Show("

Noshapefilechosen"

"

NoChoice#1"

//System.Windows.Forms.MessageBoxButtons.OK,

//System.Windows.Forms.MessageBoxIcon.Exclamation);

//Theuserdidnotchooseashapefile.TheyclickedCancelorclosedthedialogbythe"

X"

button.

//Dowhateverremedialactionsasnecessary.

NoChoice#2"

#endregion

[VisualBasic.NET]

AddShapefileUsingOpenFileDialog

AddashapefiletotheActiveViewusingtheWindows.Forms.OpenFileDialogcontrol.

ESRI.ArcGIS.Carto

ESRI.ArcGIS.DataSourcesFile

ESRI.ArcGIS.Display

ESRI.ArcGIS.Geometry

System.Windows.Forms

(NONE)

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 幼儿教育 > 幼儿读物

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1