Can anyone help me resolve this error?

Traceback(most recent call last): File "*file.py", Line 15 in if (arcpy.Describe(lyr).shapeType) == 'Polygon': AttributeError: DescribeData: Method shapeType does not exist

I am running the script below in an ArcToolbox.

aprx = arcpy.mp.ArcGISProject("CURRENT")
Map1 = aprx.listMaps("Map")[0]
#Map2 = aprx.listMaps("Map*")[1]
arcpy.env.workspace = r"T:\Risk Model\3rd Party Data\Crossings_aprx\SNV_CrossingsExport.gdb"
in_routes = arcpy.GetParameterAsText(0)
#shapeType = arcpy.Describe(lyr).shapeType
for i,lyr in enumerate(Map1.listLayers()):
#for i,lyr in enumerate(Map2.listLayers()):
for i,lyr in enumerate(Map1.listLayers()):
        if (arcpy.Describe(lyr).shapeType) == 'Polygon':
            arcpy.LocateFeaturesAlongRoutes_lr(lyr, in_routes, "RouteId", "0 Feet", arcpy.env.workspace + "//" + "{}Located{}".format(lyr,i), "MapRouteId Line FMEAS TMEAS", "FIRST", "DISTANCE", "ZERO", "FIELDS", "M_DIRECTON")
            arcpy.LocateFeaturesAlongRoutes_lr(lyr, in_routes, "RouteId", "10 Feet", arcpy.env.workspace + "//" + "{}Located{}".format(lyr,i), "MapRouteId Point StationPoint", "FIRST", "DISTANCE", "ZERO", "FIELDS", "M_DIRECTON")```


1 Answer 1


You are almost there. As I mentioned in my comment, shapeType is a Describe property disclosed if the Describe.dataType is FeatureClass. Since you are working with a map and enumerating map layers, then this FeatureClass becomes feature layer.

As you did in your previous for loop, if you place if(arcpy.Describe(lyr).dataType)=='FeatureLayer': inside your second for loop to control ... .shapeType) == 'Polygon': (and its else part), your script should work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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