ArcMap下用VBA操作图层基本的过程了。

 Private Sub UIButtonControl1_Click()
Dim pApp As IApplication
Set pApp = Application
Dim pDoc As IMxDocument
Set pDoc = pApp.Document
Dim pMap As IMap
Set pMap = pDoc.FocusMap
Dim pLayer As ILayer
Set pLayer = pDoc.SelectedLayer If (pLayer Is Nothing) Then MsgBox "请选择要计算的图层!": Exit Sub
Dim pFeatLayer As IFeatureLayer
Set pFeatLayer = pLayer Dim pFeatClass As IFeatureClass
Set pFeatClass = pFeatLayer.FeatureClass Dim outStr As String Select Case pFeatClass.ShapeType '1为point,3为polyline,4为polygon
Case
MsgBox ("当前图层为点图层")
Call compoint(pFeatClass, outStr)
Case
MsgBox ("当前图层为面图层")
Call compolyline(pFeatClass, outStr)
Case
MsgBox ("当前图层为面图层")
Call compolygon(pFeatClass, outStr)
Case Else
End Select Dim msgStr() As String
Dim maxi As Integer
ReDim Preserve msgStr()
maxi = -
For i = To CInt((Len(outStr) / ))
maxi = maxi +
ReDim Preserve msgStr(maxi)
msgStr(maxi) = Mid(outStr, * i + , )
Next
For i = To UBound(msgStr) -
MsgBox (msgStr(i))
Next End Sub
//获取点图层坐标信息
Private Function compoint(pFeatClass As IFeatureClass, ByRef outStr As String)
Dim pPnt As IPoint Dim pFeatCursor As IFeatureCursor
Set pFeatCursor = pFeatClass.Search(Nothing, False) Dim pFeature As IFeature
Set pFeature = pFeatCursor.NextFeature
Dim sName As String
Do Until pFeature Is Nothing
Set pPnt = pFeature.Shape
sName = pFeature.Value(pFeature.Fields.FindField("CITY_NAME"))
Set pFeature = pFeatCursor.NextFeature
outStr = outStr + sName + ": " + Str(pPnt.X) + "," + Str(pPnt.Y)
If pPnt.Z <> Null Then outStr = outStr + Str(pPnt.Z)
outStr = outStr + vbNewLine
Loop End Function
//获取线图层长度信息等属性信息
Private Function compolyline(pFeatClass As IFeatureClass, ByRef outStr As String)
Dim pPolyline As IPolyline
Dim pFeatCursor As IFeatureCursor
Set pFeatCursor = pFeatClass.Search(Nothing, False)
Dim pFeature As IFeature
Set pFeature = pFeatCursor.NextFeature
Dim itab As Integer
Dim sName As String Do Until pFeature Is Nothing
itab = + itab
Set pPolyline = pFeature.Shape
sName = pFeature.Value(pFeature.Fields.FindField("NAME"))
Set pFeature = pFeatCursor.NextFeature
outStr = outStr + "元素" + CStr(itab) + ": " + sName + ",长度为:" + Str(pPolyline.Length) + ";" + vbNewLine
Loop End Function
87// 获取多边形图层信息等属性信息
Private Function compolygon(pFeatClass As IFeatureClass, ByRef outStr As String)
Dim pArea As IArea
Dim pPolygon As IPolygon
Dim pFeatCursor As IFeatureCursor
Set pFeatCursor = pFeatClass.Search(Nothing, False)
Dim pPnt As IPoint
Dim pFeature As IFeature
Set pFeature = pFeatCursor.NextFeature
Dim sName As String
Do Until pFeature Is Nothing
Set pPolygon = pFeature.Shape
Set pArea = pPolygon
Set pPnt = pArea.Centroid
sName = pFeature.Value(pFeature.Fields.FindField("STATE_NAME"))
Set pFeature = pFeatCursor.NextFeature
outStr = outStr + sName + ": " + _
"周长是:" + Str(pPolygon.Length) + _
",面积是:" + Str(pArea.Area) + _
",重心是:(" + Str(pPnt.X) + "," + Str(pPnt.Y) + ")"
If pPnt.Z <> Null Then outStr = outStr + Str(pPnt.Z)
outStr = outStr + vbNewLine
Loop End Function

ArcMap中用VBA读度矢量图层信息的更多相关文章

  1. GeoServer中利用SLD配图之矢量图层配图

    文章版权由作者李晓晖和博客园共有,若转载请于明显处标明出处:http://www.cnblogs.com/naaoveGIS/. 1 背景 我们在ArcMap中可以直接通过symbol功能对图层进行定 ...

  2. (十二) WebGIS中矢量图层的设计

    文章版权由作者李晓晖和博客园共有,若转载请于明显处标明出处:http://www.cnblogs.com/naaoveGIS/. 1.前言 在前几章中我们已经了解了什么是矢量查询.屏幕坐标与地理坐标之 ...

  3. (七)WebGIS中栅格、矢量图层设计之栅格、矢量图层的本质

    文章版权由作者李晓晖和博客园共有,若转载请于明显处标明出处:http://www.cnblogs.com/naaoveGIS/. 1.何为栅格数据,何为矢量数据? 在GIS中,对于数据格式的分类,我们 ...

  4. openlayers3 在地图上叠加WFS查询矢量图层

    随着终端设备计算能力的加强,用户在使用地图的时候也须要越来越多的交互效果. 比方如今非常火的室内导航,为了获得好的用户体验,就须要当用户单击某一商店的时候该商店的颜色能对应的变化.这就须要叠加矢量图层 ...

  5. QGis(三)查询矢量图层的要素属性字段值(转载)

    QGis(三)查询矢量图层的要素属性字段值 https://github.com/gwaldron/osgearth/issues/489 当加载一个矢量图层后,如果要查看要素的属性字段值,则需要实现 ...

  6. 【07】openlayers 矢量图层

    创建地图: //创建地图 var map = new ol.Map({ //设置显示地图的视图 view: new ol.View({ center: [0, 0],//义地图显示中心于经度0度,纬度 ...

  7. asp.net用户身份验证时读不到用户信息的问题 您的登录尝试不成功。请重试。 Login控件

    原文:asp.net用户身份验证时读不到用户信息的问题 您的登录尝试不成功.请重试. Login控件 现象1.asp.net使用自定义sql server身份验证数据库,在A机器新增用户A,可以登录成 ...

  8. ArcGIS统计栅格像元值并转换为矢量图层

    很多时候,我们需要得到矢量数据区域所对应栅格数据的像元统计值(求平均.求和等),然后将获得的统计值赋给矢量图层的属性表,在ArcGIS中操作如下:(PS:第一次写技术文章,望大家多多体谅与支持,么么哒 ...

  9. Qt+QGIS二次开发:向shp矢量图层中添加新的字段

    添加一个新的字段到shp文件中,并且从Excel里导入数据到该字段.原shp文件里的字段ID应该与Excel里的字段ID一一对应才能正确的导入.下图分别是shp的字段和Excel的字段 将class字 ...

随机推荐

  1. 使用JS对form的内容验证失败后阻止提交 &&js校验表单后提交表单的三种方法总结

    1.form的两个事件 submit,提交表单,如果直接调用该函数,则直接提交表单 onSubmit,提交按钮点击时先触发,然后触发submit事件.如果不加控制的话,默认返回true,因此表单总能提 ...

  2. 并发编程之二:wait、notify、notifyAll的使用方法

    wait().notify().notifyAll()是三个定义在Object类里的方法,可以用来控制线程的状态. public final native void wait(long timeout ...

  3. Android 开发中常用 ADB 命令总结

    adb 的全称为 Android Debug Bridge,就是起到调试桥的作用.通过 adb 我们可以在 Eclipse 中方便通过 DDMS 来调试 Android 程序,说白了就是 debug ...

  4. 学习vim命令:“:w !sudo tee %”

    学习vim命令:“:w !sudo tee %” Original URL:http://www.haw-haw.org/node/1501 原文来自于commandlinefu 原文是这样解释这个命 ...

  5. css 选择器优先级的计算过程

    以下转自互联网 下面看看官方对选择器的定义:一个选择器的优先级由四个数字a,b,c,d确定.当比较两个选择器时,先比较a,a值大的优先级高,如果a相等则比较b,b值大的优先级高,以此类推.因此,无论b ...

  6. Android应用框架浅析

    http://blog.csdn.net/yanbober/article/category/3206943 Android应用层View绘制流程与源码分析   http://blog.csdn.ne ...

  7. java:jdk环境变量配置+tomcat环境变量配置

    一:JDK1.先安装jdk  查看jdk版本:   DOC下输入java -version2.配置环境变量(添加系统变量)  JAVA_HOME      D:\study\jdk-6\jdk-6(j ...

  8. java生产随机字符串

    public static String getRandomString(int length) { //length表示生成字符串的长度 String base = "abcdefghij ...

  9. (medium)LeetCode 210.Course Schedule II

    There are a total of n courses you have to take, labeled from 0 to n - 1. Some courses may have prer ...

  10. jmeter随笔(8)--请求post的 数据为空

    1.请求post的 数据为空 分析:发现是java 解决方法: 查看 2.获取文本中数据乱码问题 问题:文本保存为UTF-8编码格式 获取的数据乱码: 分析:这是编码格式的问题 解决办法: 将文件保存 ...