Simply? getting Z values into attribute table

21251
15
09-13-2010 11:47 AM
DataSteward
New Contributor III
This should be really simple and I'm surprized that an hour of looking through the forums and other support hasn't turned up an answer for me yet.  Am I just being blind?

I have a shapefile of 3D points, and I want to fill a field in the attribute table with the Z values.  Calculate Geometry does not offer Z coordinate options.  So I've tried using the Field Calculator with

[INDENT]Dim Output As Double
Dim pPoint As IPoint
Dim pZAware as IZAware
Set pPoint = [Shape]
Set pZAware = pPoint
pZAware.ZAware = true
Output = pPoint.Z
[/INDENT]

(and variants thereof)

But all I get for output is the value '1'
Tags (1)
0 Kudos
15 Replies
EricRice
Esri Regular Contributor
Eric,

The Add XY Coordinates tool will add POINT_Z and POINT_M fields when the input feature is z- and m-enabled. It's located in Data Management Tools > Features.  If you don't want the X, Y fields you can delete them and keep just the Z.

In ArcGIS 10, the Calculate Geometry has the option to get the Z for a point dataset.

I tested your code sample and it worked fine for me so there is nothing wrong with that.  What does your dataset say in the Shape field?  And how did the data get the Z values originally?


Regards,
Eric
DataSteward
New Contributor III
"Add XY Coordinates" did the trick!

I'm at version 9.3.1 - looking forward to 10.  My shape field reports "Point ZM".  The file originated as a CSV with XYZ values, turned into a shape file with "ASCII 3D to Feature Class". My code may remain a mystery, but the overall problem is solved.

Thanks!
0 Kudos
KONPETROV
Occasional Contributor III

well i have the same problem i tried but i am getting only x,y coordinates, i am using 10.2.2.

0 Kudos
XanderBakker
Esri Esteemed Contributor

You could use the python syntax and write:

!Shape!.firstPoint.Z

More examples here: ArcGIS Help (10.2, 10.2.1, and 10.2.2)

KONPETROV
Occasional Contributor III

very usefull! any suggestion if i want to create a line with a start and end point which is not drawn at the terrain but as a chord, to get  after that the z values?

0 Kudos
XanderBakker
Esri Esteemed Contributor

Hi,

Is it possible to start a new thread and include some more details about what you're after? Maybe include some sample data or an image that explains the situation?

Kind regards, Xander

0 Kudos
KONPETROV
Occasional Contributor III
0 Kudos
AdrianWelsh
MVP Honored Contributor

I'm late to the party but this tool in Pro works great!

Add Geometry Attributes—Data Management toolbox | ArcGIS Desktop 

0 Kudos
NigelBaker
New Contributor III

I have the same type of problem and simply cannot believe that this is still an issue.

I have gps data which i have extracted from photo metadata and converted to .kmz using geosetter.

I import this data using the kmz to layer tool and then save the points to a shapefile.

if i select a point the coordinates of the point are shown in the pop-up window in full with x, y and z (altitude).

then i tried both the 'Add XY Coordinates' tool which returned a 0 for all the z values and the 'add geometry attributes' tool which returned a 'null' for all the z values. the XY coordinates were written correctly.

what is the deal? it is 2019, we live in a 3D world. why is this so difficult?

please!

0 Kudos