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. Laravel中URL,ACTION,ROUTE区别

    创建路由如下所示: Route::get('articles',['uses'=>'ArticlesController@index','as'=>'articles.index']); ...

  2. 通过JSTL+EL实现循环迭代

    使用前需要导入包 jstl.jar 和 standard.jar <%@ page language="java" import="java.util.*,com. ...

  3. SQL SERVER 中的 object_id()函数

    在SQLServer数据库中,如果查询数据库中是否存在指定名称的索引或者外键约束等,经常会用到object_id('name','type')方法,做笔记如下: ? 语法:object_id('obj ...

  4. distinct 多个字段

    select distinct ID,AA,BB from tName与select distinct ID from tName有什么区别??第一种情况,distinct会不会影响AA,或者BB字段 ...

  5. Oracle自增列

    一.介绍: 在设计数据库时,有时候希望表的某一列为自增列,例如编号,本文就介绍如何在oracle数据库中实现自增列,需要两个步骤: 1)构建序列(sequence) 在oracle中sequence就 ...

  6. 微信红包签名算法 C#代码实现

    string stringA = "appid=wxd930ea5d5a258f4f&body=test&device_info=1000&mch_id=100001 ...

  7. 我自己做的网站终于上线啦,用tornado做的,求围观 www.yustock.live

    跟股票相关的一个小网站~ www.yustock.live

  8. hbase1.1.2安装

    环境:hadoop2.6.1,zk3.4.6 1.配置环境变量 sudo vi /etc/profile.d/hbase-env.sh export HBASE_HOME=/usr/local/hba ...

  9. Oracle Grid Infrastructure: Understanding Split-Brain Node Eviction (文档 ID 1546004.1)

    In this Document   Purpose   Scope   Details   What does "split brain" mean?   Why is this ...

  10. Windows操作 - Photoshop为图片添加透明立体水印

    原文地址:http://design.yesky.com/photoshop/252/2427752.shtml 本文我们介绍用Photoshop为图片添加透明立体水印的方法和技巧. 原图: 打开原图 ...