I need to know if an arcpy geometry object has z values. I have tried without success to use the has_z attribute, since to create them you must use and I have also tried to verify if the first point of the entity has a z of None: , however I do not like this last solution since it does not seem very robust and I think there could be cases in which the first point coincidentally has a z that is None even though the entity has 3D values. How can I check if an object has z values?
1 Answer 1
I tested 3 lines: 2D, 3D with values and 3D with z values set to NULL. Espression
!Shape!.firstPoint.Z
returned NULL for 2D line only:
So, it's Ok to use z value from first point.
-
Hi @FelixIP, I was interested in answering this question and have seen your response above. I tried to spoof up a test featureclass with polylines that had some Z values that were NaN. I can't reset existing Z values or create a polyline in ArcMap or ArcPro where a Z value is NaN, it always resets to zero. So how did you create your LINE_3D_NULLS layer to have polylines where 1 or more Z values are NaN and not zero? Step 4 here does not happen for me, it always goes to zero.Hornbydd– Hornbydd2021年09月12日 18:55:17 +00:00Commented Sep 12, 2021 at 18:55
-
@Horbydd this is my point, no NULL values , it refers them to zero. I used feature to 3d by attribute and pointed to 2 fields with Nulls as from and to Z.FelixIP– FelixIP2021年09月12日 19:16:45 +00:00Commented Sep 12, 2021 at 19:16
-
First I tried has_z (property?) and also failed. Help system can be very misleading:(FelixIP– FelixIP2021年09月12日 19:27:38 +00:00Commented Sep 12, 2021 at 19:27
{}
button that enables you to format any highlighted code nicely.