Howto: 计算在ArcMAP中多边形图形元素的面积
文章编号: 213
软件: ArcInfo Desktop 8.1-8.3,9.0,9.1,ArcEditor 8.1-8.3,9.0,9.1,ArcView 8.1-8.3,9.0,9.1
操作系统: PC-Intel Windows
软件: ArcInfo Desktop 8.1-8.3,9.0,9.1,ArcEditor 8.1-8.3,9.0,9.1,ArcView 8.1-8.3,9.0,9.1
操作系统: PC-Intel Windows
1 个回复
EsriSupport
赞同来自:
内容: 这个代码不是用来计算shapefiles的多边形要素的面积,或要素类,或coverage.只是用来计算,在ArcMap中通过画图工具所画的图形多边形的面积。
1.启动ArcMap。
2.创建一个新的UIButtonControl。选择Tools>Customize打开定制对话框。
3.选择Commands项。
4.从列表目录中选择UIControls。
5.从‘Save In’下拉中选择按钮要保存的格式。
-选择Untitled保存到当前的地图文档。
-选择Normal保存所有ArcMap文档
6.点New UIControl。
7.点UIButtonControl>Create.
8.把UIButtonControl拖到工具栏中。
9.关闭定制对话框
-更多的创建UIControl信息,参考ArcGIS Desktop Help中“How to create custom commands with VBA”
10.右击uIButtoncontrol,选择'View Source'。
11.拷贝以下代码到UIButtonControl单击事件中
Dim pApp As IApplication
Set pApp = Application
'-- Get the map document
Dim pDoc As IMxDocument
Set pDoc = ThisDocument
'-- Get the graphics container for the active view
Dim pAv As IActiveView
Set pAv = pDoc.ActiveView
Dim pGc As IGraphicsContainerSelect
Set pGc = pAv.GraphicsContainer
'--Make sure a graphic element is selected
If pGc.ElementSelectionCount = 0 Then
MsgBox "Please select a graphic element"
Exit Sub
End If
'-- Make sure only one element is selected
Dim pElem As IElement
If pGc.ElementSelectionCount > 1 Then
MsgBox "Only one element can be selected"
Exit Sub
End If
'-- Get the area for the selected element
Dim pPoly As IPolygon
Dim pArea As IArea
Set pElem = pGc.SelectedElement(0)
If TypeOf pElem.Geometry Is IPolygon Then
Set pArea = pElem.Geometry
'-- Send the area to the status bar
pApp.StatusBar.Message(0) = "Element Area : " & pArea.Area
'-- or a message box
MsgBox "Element Area: " & pArea.Area
End If
12.选择多边形图形元素,点UIButtonControl按钮。面积将在左下角的状态栏显示。
创建时间:2005-12-02
最近更新:2005-12-02
【原文链接】
http://support.esrichina.com.cn/2005/1202/213.html
要回复问题请先登录或注册