How to quickly grab many (over 100) feature classes from geodatabase and import into ArcMap?

07-30-2018 11:20 AM
New Contributor

Background: we have a shapefile with a County FIPS field and we have a geodatabase of many (over 3000) feature classes and the name of each FC contains the County_FIPS.. this shapefile changes from project to project (sometimes the shapefile contains 2 counties, while other times the shapefile may contain 400 counties)

Problem: many feature classes to find in geodatabase and drag into ArcMap

Question: How do we more quickly and efficiently import these feature classes into ArcMap without having to find and drag in one by one?

County FIPS is a common field in both sets of data. Knowing that, is there a Python script or Model we could create that would join these two sets of data and allow us to bring in multiple feature classes into ArcMap all at once??

Any ideas...


Austin Acton

0 Kudos
6 Replies
MVP Honored Contributor

The main tool I think you're looking for is Make Feature Layer. I'm not exactly sure what you're trying to accomplish, but I think you'll make a list of the feature classes you want to load in ArcMap, in some way, then loop through the list, calling Make Feature Layer each time.

With that said, I also suspect that you want to automate some other analysis. The usual answer to, "how do I load many layers in ArcMap?" is, "don't." Do your analysis in Python, then load the result in ArcMap to view it.

Of course, step one is learn Python, so if you haven't done that, do so, and reply with your script for more specific help.

New Contributor

Thanks for the advice Darren.

0 Kudos
MVP Esteemed Contributor

 we have a geodatabase of many (over 3000) feature classes...

Perhaps it's time to re-think your approach to data management.  Or do you really mean you have a feature class that has 3000 + features? (That sounds like a nation wide county database).  Without knowing exactly what you've got, it's hard to make a recomendation to improve your situation.

That should just about do it....
0 Kudos
New Contributor

The geodatabase contains a nationwide set of county parcels.

0 Kudos
New Contributor II

Here is a sample script to load feature classes from workspace into ArcMap. Hope it helps.

# -*- coding: utf-8 -*-
import os
import arcpy

in_workspace = arcpy.GetParameterAsText(0)
arcpy.env.workspace = in_workspace

mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd, "*")[0]

fcs = arcpy.ListFeatureClasses("", "All")
datasets = arcpy.ListDatasets("", "All")

if datasets:
    for dataset in datasets:
        ds_fcs = arcpy.ListFeatureClasses("", "All", dataset)
        for ds_fc in ds_fcs:
            fcs.append("{}\\{}".format(dataset, ds_fc))
for fc in fcs:
    # apply filter to skip unwanted feature class
    featureclass_fullpath = os.path.join(in_workspace, fc)
    featureclass_name = os.path.split(featureclass_fullpath)[1]
    temp_layer_name = "lyr_{}".format(featureclass_name)
    arcpy.MakeFeatureLayer_management(featureclass_fullpath, temp_layer_name)
    layer = arcpy.mapping.Layer(temp_layer_name) = featureclass_name
    arcpy.mapping.AddLayer(df, layer, "AUTO_ARRANGE")
# update the scale to avoid long loading
if df.scale == None or df.scale > 5000:
    df.scale = 1000

New Contributor

Thanks, I will test this script to see if we get desired result.

0 Kudos