Last active
April 17, 2017 18:31
-
-
Save maptastik/f6346eb9ee534ceb1444d1a8e1c1f130 to your computer and use it in GitHub Desktop.
Add all the feature classes in an MXD to a geodatabase
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
A Python script to take the feature classes in an MXD file and add them to a geodatabase | |
''' | |
import arcpy | |
# Specify MXD with data to send to GDB | |
# TODO Make this so you don't have to have ArcGIS open. User should be able to take a user input and export to GDB of choice | |
mxd = arcpy.mapping.MapDocument('CURRENT') | |
# Specify the data frame where your features are | |
# Allow users to input their own data frame name | |
df = arcpy.mapping.ListdataFrames(mxd, 'Layers')[0] | |
# Make list of data in data frame | |
df_list = list(df) | |
df_layer_list = [] | |
d = 0 | |
while d < len(df_list): | |
df_item = arcpy.mapping.ListLayers(mxd, '', df)[d].name | |
df_layer_list.append(df_item) | |
d+=1 | |
arcpy.FeatureClassToGeodatabase_conversion(df_layer_list, '<path to output GDB>') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment