AE 读取坐标 写入坐标 @ shp文件.docx
文本预览下载声明
ArcGIS Engine下写入、读取和显示shapfile文件中的数据2010-10-30 Saturday by sfg环境:ArcEngine 9.3 Visual Studio 2005 Windows XP语言:C++,C#主要涉及到的类库和接口:GeoDatabase(GeoDatabaseObjectModel.pdf)IWorkspaceFactory,IWorkspace,IWorkspaceEditIFeatureClass(继承于Table),IFeature ,IField,IFields, IFieldEdit,IFieldsEditIGeometryDef,IGeometryDefEditIDataSet(IGeoDataset(IFeatureDataset,IRasterDataset), Table)CartoMap,IMap,IActiveView,IGraphicsContainerILayer,ControlsMapControl,IMapControl2,IMapControlEvents2GeometryIPoint,IPolyline,IPolygon,IPointCollectionDataSourcesFileShapefileWorkspaceFactory1. 显示A. 直接调用MapControl的AddShapefile()函数String path = @“C:\”;String fileNm = “abcFile”;axMapControl1.AddShapeFile(path, fileNm);或者使用一个对话框与用户交互选择文件OpenFileDialog ofdlg = new OpenFileDialog(); ofdlg.Filter = Shapefiles (*.shp)|*.shp; ofdlg.Multiselect = false; if(ofdlg.ShowDialog() == DialogResult.OK){获取路径/文件名}B. 先将文件添加到Layer,然后将Layer添加到MapControlESRI.ArcGIS.Geodatabase.IWorkspaceFactory workspaceFactory = new ESRI.ArcGIS.DataSourcesFile.ShapefileWorkspaceFactoryClass(); ESRI.ArcGIS.Geodatabase.IFeatureWorkspace featureWorkspace = (ESRI.ArcGIS.Geodatabase.IFeatureWorkspace)workspaceFactory.OpenFromFile(System.IO.Path.GetDirectoryName(shapefileLocation), 0); //创建工作区间ESRI.ArcGIS.Geodatabase.IFeatureClass featureClass = featureWorkspace.OpenFeatureClass(System.IO.Path.GetFileNameWithoutExtension(shapefileLocation)); //打开要素集ESRI.ArcGIS.Carto.IFeatureLayer featureLayer = new ESRI.ArcGIS.Carto.FeatureLayerClass(); featureLayer.FeatureClass = featureClass; featureLayer.Name = featureClass.AliasName; featureLayer.Visible = true; ESRI.ArcGIS.Carto.IActiveView activeView = axMapControl1.ActiveView;activeView.FocusMap.AddLayer(featureLayer); //添加图层activeView.Extent = activeView.FullExtent; activeView.PartialRefresh(ESRI.ArcGIS.Carto.esriViewDrawPhase.esriViewGeography, null, null); //刷新//以上代码为C#语言2. 读取坐标数据下面都是以shapefile为数据源Method A:用Toolbar上的“Add file”按钮将shp数据添加到MapControl中,然后从MapControl中获取Layer,再获取FeatureClass。即Layer-Feat
显示全部