Select to view content in your preferred language

Copy Features (Data Management)

978
5
11-05-2012 10:08 AM
AshleeMoore
Deactivated User
Hi,

I'm using the arcpy.CopyFeatures_management function in the Python window in ArcCatalog and I'm trying to copy over multiple features from SDE into a file geodatabase. Is is possible to copy over multiple features at once, or am I going to have to do it individually? I was successful copying over one feature, but when I try multiple features using the syntax arcpy.CopyFeature_management(["input 1", "input 2", etc],output) I don't get a valid result.

I don't use Python very often, so any help you might have would be great. Thanks!

Ashlee
Tags (2)
0 Kudos
5 Replies
MathewCoyle
Honored Contributor
Sounds like you want to do a merge not a copy.
0 Kudos
by Anonymous User
Not applicable
You can use a list with a for loop to accomplish this.  For example you could try something like this:

arcpy.env.workspace = r'your\sde_gdb\here'
outgdb = r'new\gdb\location'
for fc in arcpy.ListFeatureClasses():  # this lists feature classes inside gdb
    fcname = fc + '_copy'
    arcpy.FeatureClassToFeatureClass_conversion(fc, outgdb, fcname)


OR you can make a list or tuple containing the names of the feature classes to copy and use a for loop:

import arcpy, os
from os import path as p

sde_gdb = r'your\sde_gdb\here'
outgdb = r'new\gdb\location'
fclist = ['Roads', 'Structures', 'Parcels', 'Hydrants']
for fc in fclist:
    fc_path = p.join(sde_gdb,fc)
    fcname = fc + '_copy'
    arcpy.FeatureClassToFeatureClass_conversion(fc_path, outgdb, fcname)
0 Kudos
LucasDanzinger
Esri Frequent Contributor
I think the Feature Class to Geodatabase tool should do what you want. It is the equivalent of right clicking a geodatabase and selecting import multiple.
0 Kudos
AshleeMoore
Deactivated User
Thanks everyone for all the feedback! I think I've got it figured out now. 😄

I appreciate the help!

Ashlee
0 Kudos
NobbirAhmed
Esri Alum
Could you please let others know your solution? It'll help other users visiting this thread. If your solution include one of the suggestions please mark that as answered. That'll also be helpful. Thanks.
0 Kudos