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. Navicat MySQL连接Linux下MySQL的问题解决方案

    Error1: 2003:Can't connect to MySQL server on 'localhost' 解决方法:关闭Linux的防火墙功能. #chkconfig iptables of ...

  2. Java多线程之新类库中的构件DelayQueue

    DelayQueue 是一个无界的BlockingQueue,用于放置实现了Delayed接口的对象,其中的对象只能在其到期时才能从队列中取走.这种队列是有序的,即队头对象的延迟到期时间最长.注意:不 ...

  3. java web session监听销毁跳转

    1.了解如何使用HttpSessionListener监听session的销毁. 2.了解如何使用HttpSessionBindingListener监听session的销毁. 一. 使用HttpSe ...

  4. Jmeter-Maven-Plugin高级应用:Selecting Tests To Run

    地址:https://github.com/jmeter-maven-plugin/jmeter-maven-plugin/wiki/Advanced-Configuration Selecting ...

  5. [ActionScript 3.0] AS3 绘制正八面体(线条)

    分析: 将八面体置于3D坐标系中,其中心的坐标位于原点(0,0,0),让八面体的六个顶点恰好位于3D坐标系的x轴.y轴和z轴上,则从八面体的中心到这六个顶点的距离是相等的.我们可以假设这个距离为r,则 ...

  6. Java SE 第十六讲----面向对象特征之继承

    1.继承(inheritance):Java是单继承的,意味着一个类只能从另一个类继承(被继承的类叫做父类也叫[基类 baseclass]),继承的类叫做子类,java中的继承使用extends关键字 ...

  7. Go 支持Protocol Buffers的配置

    安装 protoc (The protocol compiler)是由C++写的,支持的 C++.Java.Python.Objective-C.C#.JavaNano.JavaScript.Ruby ...

  8. Python子类方法的调用(类方法)

    class S(object): def Test(self): print("TEST") @classmethod def Test02(cls): print("c ...

  9. IntelliJ IDEA调整控制台输出字体大小

    File->Settings->Editor->Colors & Fonts->Console Font Size: 16

  10. MS Sqlserver 备份数据库SQL

    通过作业的方式调用SQL执行自动备份,可以解决忘记备份数据库的问题,记录一下 declare @FileFullName varchar(40); declare @FileName varchar( ...