在ARCGIS属性表中增加需要的字段,并自动赋值

ARCGIS属性表中增加需要的字段,并自动赋值

 

ARCGIS属性表中增加需要的字段,并自动赋值

使用方法
1
打开属性表,选择计算的字段,右点选择Calculate Values2.选择,进入Field Calculator
2
选择Advance选项;
3
Pre-Logic VBA Script Code编辑框中输入VBA代码;
4
在下面编辑框中输入赋值部分.


1--
点坐标X
VBA
部分:
Dim pGeo As IGeometry
Set pGeo = [Shape]
Dim pPoint As IPoint
Set pPoint = pGeo
赋值部分:
pPoint.X

2--
点坐标Y
VBA
部分:
同上
赋值部分:
pPoint.Y

坐标值为文件存储的固有值,和是否使用On the Fly坐标表示无关。返回当前显示的坐标值参看8,9

3--
多边形周长
VBA
部分:
Dim pGeo As IGeometry
Set pGeo = [Shape]
Dim pPolygon As IPolygon
Set pPolygon = pGeo
赋值部分:
pPolygon.Length

4--
多边形面积
VBA
部分:
Dim pGeo As IGeometry
Set pGeo = [Shape]
Dim pPolygon As IPolygon
Set pPolygon = pGeo
Dim pArea As IArea
Set pArea = pPolygon
赋值部分:
pArea.Area

5--
多边形重心X
VBA
部分:
Dim pGeo As IGeometry
Set pGeo = [Shape]
Dim pPolygon As IPolygon
Set pPolygon = pGeo
Dim pArea As IArea
Set pArea = pPolygon
Dim pPoint As IPoint
Set pPoint = pArea.Centroid
赋值部分:
pPoint.X

6--
多边形重心Y
VBA
部分:
同上
赋值部分:
pPoint.Y

7--Polyline
长度
VBA
部分:
Dim pGeo As IGeometry
Set pGeo = [Shape]
Dim pPolyline As IPolyline
Set pPolyline = pGeo
Dim pCurve As IPolycurve
Set pCurve = pPolyline
赋值部分:
pCurve.Length

8--
表示点坐标X
VBA
部分:
Dim pDoc As IMxDocument
Set pDoc = ThisDocument
Dim pSpRef As ISpatialReference
Set pSpRef = pDoc.FocusMap.SpatialReference

Dim pClone As IClone
Set pClone = [Shape]
Dim pGeo As IGeometry
Set pGeo = pClone.Clone
Dim pPoint as IPoint
Set pPoint = pGeo

pGeo.Project pSpRef
赋值部分:
pPoint.X

9--
表示点坐标Y
VBA
部分:
同上
赋值部分:
pPoint.Y

坐标值为On the Fly显示的坐标,不是文件存储的固有坐标

10--
连续编号
VBA
部分:
Static lCount as long
lCount=lCount+1
赋值部分:
lCount (
1开始)
lCount-1 (
0开始)

来自:http://blog.myspace.cn/e/404730047.htm

你可能感兴趣的:(vba,存储)