Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am trying to determine whether my shape file that I pass is in M-aware (has M value). I keep getting an error

Attribute Error: 'Polyline' object has no attribute 'hasM'

Not sure what I am doing wrong. Any help would be greatly appreciated.

import arcpy

def ValidInputGeometry(feat):
    is_valid_poly_line = False
    is_m_enabled = False
    error_msg = None
    if feat.type == "polyline":
        if is_m_enabled == feat.hasM:
            is_valid_poly_line = True
        else:
            error_msg = "The input geometry is not M-Aware"
    else:
        error_message = "The input geometry is not a polyline"
    return (is_valid_poly_line, error_msg)



station_interval = 10000
in_polyline_m_layer = "C:/Users/Algorithm/LWOB_levee.shp"
target_feature_rows = arcpy.SearchCursor(in_polyline_m_layer, "FID = 0", "", "", "")
layer_description = arcpy.Describe(in_polyline_m_layer)
shape_field = layer_description.ShapeFieldName

for row in target_feature_rows:
    feat = row.getValue(shape_field)

    (Valid, Msg) = ValidInputGeometry(feat)    
share|improve this question
1  
Try arcpy.Describe(in_polyline_m_layer).hasM. –  blah238 Mar 8 '13 at 19:57
1  
Or with your own code, layer_description.hasM ... a geometry object does not have a hasM property, but it does have a construction parameter hasM -- which may be the confusion. –  awesomo Mar 8 '13 at 20:26
    
Thanks alot. It worked like a charm –  user1898629 Mar 8 '13 at 21:23

1 Answer 1

It appears that the geometry objects returned from cursors are not fully attributed (no hasM, hasZ, etc.) but you can find out whether the feature class itself supports M values using the feature class Describe object's hasM property:

arcpy.Describe(yourFeatureClass).hasM
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.