I need to get features in a File GeoDatabase feature class whose "fieldName" (string field) value matches the value of "strValue" (string variable). While I know there are features satisfying this condition, Make Feature Layer seems to return an empty layer (the "Describe" object of it has an empty "FIDSet" list). On the other hand search cursor with the same SQL expression successfully returns those features. I'm scratching my head what I am missing.

This is the where clause:

wc = arcpy.AddFieldDelimiters(FGDB_FC, fieldName) + ' = ' + '\'' + strValue + '\''

This worked as expected:

rows = arcpy.SearchCursor(FGDB_FC, wc)

But this returned a seemingly empty feature layer (dd.FID has no element):

arcpy.MakeFeatureLayer_management(FGDB_FC, "fl", wc)
dd = arcpy.Describe("fl")
print dd.FIDSet.split(';')
  • 2
    arcpy.SearchCursor has been superceded by arcpy.da.SearchCursor. String math has been superceded by using string.format(). You should always inlcude the ouput of a diagnotic print statement showing the final expression. It's difficult to determine what is wrong with fragmentary code samples.
    – Vince
    Feb 21, 2018 at 14:43

1 Answer 1


I just experimented with this, and yes indeed it returns and empty FID set. But that doesn't mean that there is nothing in your layer. If you do this in commandline, you can see the results of the MakeFeatureLayer does use the where clause. If you want to see how many are returned you can use the GetCount tool.

wc = arcpy.AddFieldDelimiters(FGDB_FC, fieldName) + " = '%s'"%strValue
print wc #confirm the clause
lyr = arcpy.MakeFeatureLayer_management(FGDB_FC, "fl", wc)[0]
print arcpy.GetCount_management(lyr)[0]

You could also use your layer in a searchcursor.

with arcpy.da.SearchCursor(lyr,["*"]) as sc:
    for row in sc:
        print row[0] #prints the fid since I used * for the fields

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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