Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

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
            error_msg = "The input geometry is not M-Aware"
        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
Try arcpy.Describe(in_polyline_m_layer).hasM. – blah238 Mar 8 '13 at 19:57
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

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:

share|improve this answer

Your Answer


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.