Feature Class To Feature Class (Conversion)

Summary

Converts a shapefile, coverage feature class, or geodatabase feature class to a shapefile or geodatabase feature class.

Usage

Syntax

FeatureClassToFeatureClass_conversion (in_features, out_path, out_name, {where_clause}, {field_mapping}, {config_keyword})
ParameterExplanationData Type
in_features

The feature class or feature layer that will be converted.

Feature Layer
out_path

The location in which the output feature class will be created. This can be either a geodatabase or a folder. If the output location is a folder, the output will be a shapefile.

Workspace;Feature Dataset
out_name

The name of the output feature class.

String
where_clause
(Optional)

An SQL expression used to select a subset of features. The syntax for the expression differs slightly depending on the data source. For example, if you're querying file or ArcSDE geodatabases, shapefiles, or coverages, enclose field names in double quotes:

"MY_FIELD"

If you're querying personal geodatabases, enclose fields in square brackets:

[MY_FIELD]

In Python, strings are enclosed in matching single or double quotes. To create a string that contains quotes (as is common with a WHERE clause in SQL expressions), you can escape the quotes (using a backslash) or triple quote the string. For example, if the intended WHERE clause is

"CITY_NAME" = 'Chicago'

you could enclose the entire string in double quotes, then escape the interior double quotes like this:

" \"CITY_NAME\" = 'Chicago' "

Or you could enclose the entire string in single quotes, then escape the interior single quotes like this:

' "CITY_NAME" = \'Chicago\' '

Or you could enclose the entire string in triple quotes without escaping:

""" "CITY_NAME" = 'Chicago' """

For more information on SQL syntax and how it differs between data sources, see the help topic SQL reference for query expressions used in ArcGIS.

SQL Expression
field_mapping
(Optional)

The fields and field contents chosen from the input feature class. You can add, rename, or delete output fields as well as set properties such as data type and merge rule.

Merge rules allow you to specify how values from two or more input fields are merged into a single output value. There are several merge rules that you can use:

  • First—Use the first input field's values to populate the output field.
  • Last—Use the last input field's values to populate the output field.
  • Join—Concatenate (join) all input fields' values to populate the output field.
  • Sum—Calculate the total of all input fields' values.
  • Mean—Calculate the mean (average) of all input fields' values.
  • Median—Calculate the median (middle) value.
  • Mode—Use the value with the highest frequency.
  • Min—Use the minimum value of all input fields' values.
  • Max—Use the maximum value of all input fields' values.
  • Standard deviation—Use the standard deviation classification method on all input fields' values.
  • Count—Find the number of records included in the calculation.

Learn more about choosing and setting the output fields.

Field Mappings
config_keyword
(Optional)

Specifies the storage parameters (configuration) for geodatabases in file and ArcSDE geodatabases. Personal geodatabases do not use configuration keywords.

ArcSDE configuration keywords for ArcSDE Enterprise Edition are set up by your database administrator.

String

Code Sample

FeatureClassToFeatureClass example (Python window)

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

import arcpy
from arcpy import env
env.workspace = "C:/data/GreenvalleyDB.mdb/Public Buildings"
arcpy.FeatureClassToFeatureClass_conversion("buildings_point", 
                                            "C:/output/output.gdb", 
                                            "buildings_point")
FeatureClassToFeatureClass example 2 (stand-alone script)

The following stand-alone script demonstrates how to use the FeatureClassToFeatureClass tool.

# Name: FeatureClassToFeatureClass_Example2.py
# Description: Use FeatureClassToFeatureClass with an expression to create a subset
#  of the original feature class.  

 
# Import system modules
import arcpy
from arcpy import env
 
# Set environment settings
env.workspace = "C:/data/GreenvalleyDB.mdb/Public Buildings"
 
# Set local variables
inFeatures = "buildings_point"
outLocation = "C:/output/output.gdb"
outFeatureClass = "postoffices"
delimitedField = arcpy.AddFieldDelimiters(env.workspace, "NAME")
expression = delimitedField + " = 'Post Office'"
 
# Execute FeatureClassToFeatureClass
arcpy.FeatureClassToFeatureClass_conversion(inFeatures, outLocation, 
                                            outFeatureClass, expression)

Environments

Related Topics

Licensing Information

ArcView: Yes
ArcEditor: Yes
ArcInfo: Yes

11/14/2011