Copy Features (Data Management)

License Level:BasicStandardAdvanced

Summary

Copies features from the input feature class or layer to a new feature class. If the input is a layer which has a selection, only the selected features will be copied. If the input is a geodatabase feature class or shapefile, all features will be copied.

Usage

Syntax

CopyFeatures_management (in_features, out_feature_class, {config_keyword}, {spatial_grid_1}, {spatial_grid_2}, {spatial_grid_3})
ParameterExplanationData Type
in_features

The features to be copied.

Feature Layer;Raster Catalog Layer
out_feature_class

The feature class which will be created and to which the features will be copied. If the output feature class already exists and the overwrite option is set to true, the output will be deleted first. If the output feature class already exists and the overwrite option is set to false, the operation will fail.

Feature Class
config_keyword
(Optional)

Geodatabase configuration keyword to be applied if the output is an ArcSDE geodatabase or file geodatabase.

String
spatial_grid_1
(Optional)

The Spatial Grid 1, 2, and 3 parameters apply only to file geodatabases and certain ArcSDE geodatabase feature classes. If you are unfamiliar with setting grid sizes, leave these options as 0,0,0 and ArcGIS will compute optimal sizes for you. For more information about this parameter, refer to the Add Spatial Index tool documentation.

Double
spatial_grid_2
(Optional)

Cell size of the second spatial grid. Leave the size at 0 if you only want one grid. Otherwise, set the size to at least three times larger than Spatial Grid 1.

Double
spatial_grid_3
(Optional)

Cell size of the third spatial grid. Leave the size at 0 if you only want two grids. Otherwise, set the size to at least three times larger than Spatial Grid 2.

Double

Code Sample

CopyFeatures example (Python window)

The following Python window script demonstrates how to use the CopyFeatures tool in immediate mode.

import arcpy
from arcpy import env
env.workspace = "C:/data"
arcpy.CopyFeatures_management("climate.shp", "C:/output/output.gdb/climate")
CopyFeatures example 2 (stand-alone script)

The following stand-alone script demonstrates how to use CopyFeatures to copy the shapefiles in a folder to a file geodatabase.

# Name: CopyFeatures_Example2.py
# Description: Convert all shapefiles in a folder to geodatabase feature classes
# Requirements: os module
 
# Import system modules
import arcpy
from arcpy import env
import os
 
# Set environment settings
env.workspace = "C:/data"
 
# Set local variables
outWorkspace = "c:/output/output.gdb"
 
# Use ListFeatureClasses to generate a list of shapefiles in the
#  workspace shown above.
fcList = arcpy.ListFeatureClasses()
 
# Execute CopyFeatures for each input shapefile
for shapefile in fcList:
    # Determine the new output feature class path and name
    outFeatureClass = os.path.join(outWorkspace, shapefile.strip(".shp"))
    arcpy.CopyFeatures_management(shapefile, outFeatureClass)

Environments

Related Topics

Licensing Information

ArcGIS for Desktop Basic: Yes
ArcGIS for Desktop Standard: Yes
ArcGIS for Desktop Advanced: Yes
11/18/2013