Select to view content in your preferred language

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

896
6
07-30-2018 11:20 AM
AustinActon
Emerging 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...

Thanks,

Austin Acton

0 Kudos
6 Replies
DarrenWiens2
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.

AustinActon
Emerging Contributor

Thanks for the advice Darren.

0 Kudos
JoeBorgione
MVP Emeritus

 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
AustinActon
Emerging Contributor

The geodatabase contains a nationwide set of county parcels.

0 Kudos
MemoryBlue
Emerging Contributor

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)
    layer.name = featureclass_name
    arcpy.mapping.AddLayer(df, layer, "AUTO_ARRANGE")
    arcpy.Delete_management(temp_layer_name)
    
# update the scale to avoid long loading
if df.scale == None or df.scale > 5000:
    df.scale = 1000

arcpy.RefreshActiveView()
arcpy.RefreshTOC()
AustinActon
Emerging Contributor

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

0 Kudos