Get the maximum hight of a 3D line?

547
1
Jump to solution
03-08-2021 03:03 AM
JohannesBierer
Occasional Contributor III

Hello,

I would like to get the maximum hight of a line feature but it doesn't work with FeatureClassToNumPyArray?

I tried the following code:

 

def Sperren_interpShape(self):

        arcpy.CheckOutExtension("3D")

        desc = arcpy.Describe(inSperren)

        outFC = "{0}_3D".format(desc.basename)
        method = "BILINEAR"
        # Execute InterpolateShape
        arcpy.ddd.InterpolateShape(inHights, inSperren, outFC, 
                                   "", "", method, True)
    
        arcpy.CheckInExtension("3D")

        arcpy.MakeFeatureLayer_management(outFC, outLyr) 
        with arcpy.da.SearchCursor(outLyr, "OBJECTID") as cursor:
            for row in cursor:
                print row[0]
                sel = "{} = {}".format("OBJECTID", row[0])
                print sel
                arcpy.SelectLayerByAttribute_management(outLyr, "NEW_SELECTION", sel)
                
                arr = arcpy.da.FeatureClassToNumPyArray(outLyr, ["OBJECTID", 'SHAPE@Z'])
                
                print arr
                print np.amax(arr.astype(np.float))

 

but it only results in the following print statements:

1
OBJECTID = 1
[(1, nan)]
1.0

What does "nan" means? Are there better ways to get the maximum hight of a 3D line?

 

Working in 10.6.1?

 

0 Kudos
1 Solution

Accepted Solutions
DanPatterson
MVP Esteemed Contributor

nan .... Not a Number

FeatureClassToNumPyArray—ArcGIS Pro | Documentation

SHAPE@M and SHAPE@Z tokens will only return values if the in_table contains point features and is m-aware (or z-aware). If the in_table contains polygon, polyline, or multipart features, SHAPE@M and SHAPE@Z will return a nan. Any feature class that is not m-aware or z-aware will not support SHAPE@M and SHAPE@Z tokens.

Convert polyline or polygon features to a point featureclass first

then use explode_to_points=True

FeatureClassToNumPyArray (in_table, field_names, {where_clause}, {spatial_reference}, {explode_to_points}, {skip_nulls}, {null_value})


... sort of retired...

View solution in original post

0 Kudos
1 Reply
DanPatterson
MVP Esteemed Contributor

nan .... Not a Number

FeatureClassToNumPyArray—ArcGIS Pro | Documentation

SHAPE@M and SHAPE@Z tokens will only return values if the in_table contains point features and is m-aware (or z-aware). If the in_table contains polygon, polyline, or multipart features, SHAPE@M and SHAPE@Z will return a nan. Any feature class that is not m-aware or z-aware will not support SHAPE@M and SHAPE@Z tokens.

Convert polyline or polygon features to a point featureclass first

then use explode_to_points=True

FeatureClassToNumPyArray (in_table, field_names, {where_clause}, {spatial_reference}, {explode_to_points}, {skip_nulls}, {null_value})


... sort of retired...
0 Kudos