Move Feature Classes from File Geodatabase to TOC - ArcPy

383
3
02-26-2018 07:21 AM
Business_IntelligenceSoftware
Occasional Contributor

I have a need for some ArcPy code that will allow me to move feature classes in my File Geodatabase to the Table of Contents in my ArcGIS Pro project. However, I have no idea how to do this and I can not find any examples of this online. 

Is this possible? Could someone please show me how to do this?

0 Kudos
3 Replies
BlakeTerhune
MVP Regular Contributor
Business_IntelligenceSoftware
Occasional Contributor

Thanks for the quick response Blake. I'm not sure this is exactly what I'm looking for though.

Maybe I should explain a little more. Ideally, it would be great if after I run my summarize within script, it takes the output feature class and adds it to the contents pane. For example:

# import system modules 
import arcpy

# Set environment settings
arcpy.env.workspace = 'C:/data/city.gdb'

#  Set local variables
polys = 'neighborhoods'
points = 'crimes'
outFeatureClass = 'crimes_aggregated'
keepAll = 'KEEP_ALL'
sumFields = [['Damages', 'SUM'], ['VICTIM_AGE', 'MEAN']]
addShapeSum = 'ADD_SHAPE_SUM'
groupField = 'Crime_type'
addMinMaj = 'ADD_MIN_MAJ'
addPercents = 'ADD_PERCENT'
outTable = 'crimes_aggregated_groups'

arcpy.SummarizeWithin_analysis(polys, points, outFeatureClass, keepAll, 
                               sumFields, addShapeSum, '', groupField, 
                               addMinMaj, addPercents, outTable)

So after the "arcpy.SummarizeWithin_analysis()" I would like to add a piece of code that would take that feature class that was just created and move it to the contents pane.

0 Kudos
DanPatterson_Retired
MVP Esteemed Contributor

Your options at the global level are to 'add results to display' in your overall settings, or MakeFeatureLayer.

Generally results are added to the display IF the project is running and the script is attached to a tool.  If you are running a standalone script, then make a layer file and use Blake's suggestion.