//这是直接根据路径名称加载
private voidmenuAddShp_Click(object sender, EventArgs e)
{
IWorkspaceFactory pWorkspaceFactory = new ShapefileWorkspaceFactory()
IWorkspace pWorkspace = pWorkspaceFactory.OpenFromFile(@"D:\GIS-Data",0)
IFeatureWorkspace pFeatureWorkspace =pWorkspace as IFeatureWorkspace
IFeatureClass pFC =pFeatureWorkspace.OpenFeatureClass("continent.shp")
IFeatureLayer pFLayer = new FeatureLayerClass()
pFLayer.FeatureClass = pFC
pFLayer.Name = pFC.AliasName
ILayerpLayer = pFLayer as ILayer
IMappMap = axMapControl1.Map
pMap.AddLayer(pLayer)
axMapControl1.ActiveView.Refresh()
}
//这段是利用对话框添加
从工具箱往窗体上添加一个OpenFileDialog控件。
private voidmenuAddShp_Click(object sender, EventArgs e)
{
IWorkspaceFactorypWorkspaceFactory = new ShapefileWorkspaceFactory()
openFileDialog1.Filter = "shapefile文件(*.shp)|*.shp"
openFileDialog1.InitialDirectory = @"D:\GIS-Data"
openFileDialog1.Multiselect = false
DialogResultpDialogResult = openFileDialog1.ShowDialog()
if(pDialogResult != DialogResult.OK)
return
stringpPath = openFileDialog1.FileName
stringpFolder = Path.GetDirectoryName(pPath)
stringpFileName = Path.GetFileName(pPath)
IWorkspacepWorkspace = pWorkspaceFactory.OpenFromFile(pFolder,0)
IFeatureWorkspacepFeatureWorkspace = pWorkspace as IFeatureWorkspace
IFeatureClasspFC = pFeatureWorkspace.OpenFeatureClass(pFileName)
IFeatureLayerpFLayer = new FeatureLayerClass()
pFLayer.FeatureClass = pFC
pFLayer.Name = pFC.AliasName
ILayerpLayer = pFLayer as ILayer
IMap pMap =axMapControl1.Map
pMap.AddLayer(pLayer)
axMapControl1.ActiveView.Refresh()
}
arcgis中的 .shp文件存的是图形的信息,.dbf中存的是属性的信息,dbf文件是shp文件的一部分。将数据导入ArcGIS可以通过在arccatalog建立个人数据库,将数据导入数据库里,然后就可以在arcmap里导入了。
利用arcgis软件,打开属性表,选择对应的记录,右击单击有选项export就可以导出为dbf格式数据,直接就可以用excel打开并编辑计算;若无选中记录,默认全部导出;数据计算完毕后,仍保存为dbf格式;
在arcmap地图窗口打开原图层数据和重新计算保存后的表格数据,在图层上右击利用join命令,选择一个能唯一标识图形和属性表的字段,就可以把新数据连接到原始图层中。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)