ArcMap中用VBA读度矢量图层信息
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读度矢量图层信息的更多相关文章
- GeoServer中利用SLD配图之矢量图层配图
文章版权由作者李晓晖和博客园共有,若转载请于明显处标明出处:http://www.cnblogs.com/naaoveGIS/. 1 背景 我们在ArcMap中可以直接通过symbol功能对图层进行定 ...
- (十二) WebGIS中矢量图层的设计
文章版权由作者李晓晖和博客园共有,若转载请于明显处标明出处:http://www.cnblogs.com/naaoveGIS/. 1.前言 在前几章中我们已经了解了什么是矢量查询.屏幕坐标与地理坐标之 ...
- (七)WebGIS中栅格、矢量图层设计之栅格、矢量图层的本质
文章版权由作者李晓晖和博客园共有,若转载请于明显处标明出处:http://www.cnblogs.com/naaoveGIS/. 1.何为栅格数据,何为矢量数据? 在GIS中,对于数据格式的分类,我们 ...
- openlayers3 在地图上叠加WFS查询矢量图层
随着终端设备计算能力的加强,用户在使用地图的时候也须要越来越多的交互效果. 比方如今非常火的室内导航,为了获得好的用户体验,就须要当用户单击某一商店的时候该商店的颜色能对应的变化.这就须要叠加矢量图层 ...
- QGis(三)查询矢量图层的要素属性字段值(转载)
QGis(三)查询矢量图层的要素属性字段值 https://github.com/gwaldron/osgearth/issues/489 当加载一个矢量图层后,如果要查看要素的属性字段值,则需要实现 ...
- 【07】openlayers 矢量图层
创建地图: //创建地图 var map = new ol.Map({ //设置显示地图的视图 view: new ol.View({ center: [0, 0],//义地图显示中心于经度0度,纬度 ...
- asp.net用户身份验证时读不到用户信息的问题 您的登录尝试不成功。请重试。 Login控件
原文:asp.net用户身份验证时读不到用户信息的问题 您的登录尝试不成功.请重试. Login控件 现象1.asp.net使用自定义sql server身份验证数据库,在A机器新增用户A,可以登录成 ...
- ArcGIS统计栅格像元值并转换为矢量图层
很多时候,我们需要得到矢量数据区域所对应栅格数据的像元统计值(求平均.求和等),然后将获得的统计值赋给矢量图层的属性表,在ArcGIS中操作如下:(PS:第一次写技术文章,望大家多多体谅与支持,么么哒 ...
- Qt+QGIS二次开发:向shp矢量图层中添加新的字段
添加一个新的字段到shp文件中,并且从Excel里导入数据到该字段.原shp文件里的字段ID应该与Excel里的字段ID一一对应才能正确的导入.下图分别是shp的字段和Excel的字段 将class字 ...
随机推荐
- linux命令行下导出导入.sql文件
一.导出数据库用mysqldump命令(注意mysql的安装路径,即此命令的路径):1.导出数据和表结构(以管理员身份运行): ------------------------------------ ...
- java泛型的使用
package com.wzh.test.generic; import java.util.ArrayList; import java.util.HashMap; import java.util ...
- 将access数据库导入mysql
一般地,直接在mysql端,导入时选择access文件就行:但是若access数据库版本太老,导入mysql时会出错: 这时,就需要借助access 2003,对原始数据进行转换为2003版本数据,即 ...
- java小程序 实例 二分法查找
使用二分法在一个数组中查找一个数: package com.test; public class BinaryFind { private final static int size = 500000 ...
- tomcat 内存溢出
PermGen space的全称是Permanent Generation space,是指内存的永久保存区域,这一部分用于存放Class和Meta的信息,Class在被 Load的时候被放入Perm ...
- [ActionScript 3.0] AS3.0 获取像素点的灰度
/** * 获取像素点的灰度 * @color 像素点的颜色值 * @return uint */ function getGray(color:uint):uint { return getR(co ...
- BestCoder Round #79 (div.2)
1001.没推到题解那么细,枚举一下也可以.用通分可以避免小数精度问题. #include<iostream> #include<stdio.h> using namespac ...
- 解决WinForm(C#)中MDI子窗体最大化的问题
“用MDI方式打开一个子窗口体后,总是不能最大化显示,明明子窗口体的WindowState设置为Maximized?”,相信有很多人会遇到这的样问题,请按下面的方法设置即可使MDI子窗体最大化: 1. ...
- OC基础(7)
封装 继承基本概念 继承相关特性 多态基本概念 多态的实现 *:first-child { margin-top: 0 !important; } body > *:last-child { m ...
- oracle 事务测试
此文章是根据官方改变 模拟帐户转账流程 1.JOHN帐户扣除-DAVID帐户增加-记录日志-事务提交 三个操作必须全部完成此事务才完成,否则失败 创建帐户余额表自增字段自增序列: ; 创建支票表 ...