Add to Map only features with certain names in gdbs

549
1
Jump to solution
10-01-2019 09:06 AM
MalcolmLittle
New Contributor III

Hello,

I am trying to add data to my ArcPro map that resides in a geodatabase. Thing is, I only want to bring in features whose names end in "...RS75m", but there are many other features that I do not want to bring in.

The following snapshot highlights the particular features I want to add to the map (in red), while I do not want to add the other features. Is there an automated way to select based on a wildcard of a features name, or Python console option inside ArcMap?

0 Kudos
1 Solution

Accepted Solutions
JoshuaBixby
MVP Esteemed Contributor

Try the following in the interactive Python window when you have the map open you want the layers in:

import os
gdb = # set path to geodatabase containing feature classes
walk = arcpy.da.Walk(gdb)
for root, dirs, files in walk:
    for fc in files:
        if fc.endswith("_RS75m"):
            arcpy.MakeFeatureLayer_management(os.path.join(root,fc))

View solution in original post

1 Reply
JoshuaBixby
MVP Esteemed Contributor

Try the following in the interactive Python window when you have the map open you want the layers in:

import os
gdb = # set path to geodatabase containing feature classes
walk = arcpy.da.Walk(gdb)
for root, dirs, files in walk:
    for fc in files:
        if fc.endswith("_RS75m"):
            arcpy.MakeFeatureLayer_management(os.path.join(root,fc))