I'm trying to clip layers in a dataframe with a polygon using python and I've done this python script but it's giving this error:

ERROR 000840: The value is not a Feature Layer

import arcpy, os
from arcpy import env
from arcpy import mapping
mxd = mapping.MapDocument("Current")
df = mxd.activeDataFrame

for layer in mapping.ListLayers(mxd,"", df):
    clipped_fc = env.scratchFolder + os.sep + "_clipped.shp"
    arcpy.Clip_analysis(FL, polygon,clipped_fc)

del layer
del mxd
del df

1 Answer 1


1.Which line returns the error? Maybe you should check if the layer can be converted to a feature layer and clipped using

if layer.isFeatureLayer:

2.Besides this, your script will overwrite clipped_fc at every iteration. Change the name to something like clipped_fc = env.scratchFolder + os.sep + layer.name + "_clipped.shp". Check that the layers' name is a valid value for naming a shapefile.

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.