Is This Content Helpful?
We're glad to know this article was helpful.
Instructions provided describe how to calculate X, Y, and Z values in an attribute table using the Field Calculator and Visual Basic for Applications (VBA).
These code examples return a value of type 'double', so use them to calculate either an existing field of type 'double' or a new field of type 'double' that has been added to the table.
This procedure can be used with new or existing fields in an attribute table. If it is necessary to add new fields to the attribute table, see the ArcGIS Desktop Help topic 'Adding and deleting fields in a table'.
Dim Output As Double
Dim pPoint As IPoint
Set pPoint = [Shape]
Output = pPoint.X
The units of the calculated values are the units that the features are stored in, not the map units or display units of the data frame currently worked on.
If the data is stored in feet, the calculated values appear in feet. To allow calculated data to be in different units, other than the data's units,do one of the following:
Add a conversion into the calculation expression.
Project the data into a coordinate system that uses the units the values should be in, and then perform the calculation.
Output = pPoint.Y
Output = pPoint.Z
A 3D Analyst license is not required to extract Z values from the shape field of an existing 3D layer.