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
-
The Field Map parameter controls how the input fields in the Input Features will be written to the Output Features.
- To drop fields during the conversion, delete input fields from the Field Map. This will not affect the input feature class.
- A single output field can be generated from multiple input fields if a new field is created and the contents of the output field are generated from multiple (differently named) fields.
- The data type of an output field will default to the same as the data type of the first input field (of that name) it encounters. The data type may be changed manually at any time to any valid data type. All valid data types will be listed if the tool's dialog box is used.
- When using the Merge rule, you can specify your own delimiter such as a space, comma, period, dash, and so on. If you want to use a space, make sure your mouse pointer is at the start of the input box and click the space bar once.
- There are a number of Merge rules available: first, last, join, sum, mean, median, min, max, and standard deviation.
- Format options are only available on input fields of type text (and in conjunction with the Join merge rule). You can specify start point, end point, and so on. Format allows you to apply your changes to the selected input field or apply them to all occurrences of the same input field.
- Standard deviation should not be performed on a single input because values can't be divided by zero, so standard deviation is not a valid option for single inputs.
-
The Copy Features tool can also be used to convert a shapefile, coverage feature class, or geodatabase (file, personal, or ArcSDE) feature class to a shapefile or geodatabase (file, personal, or ArcSDE) feature class.
-
An SQL expression can be used to select a subset of features. For further details on the syntax for the Expression parameter, see Building an SQL Expression or SQL Reference.
When converting geodatabase data that has attribute domains to a shapefile, dBase table, or coverage, both the domain codes and domain descriptions will be included in the output. The domain descriptions will be in a new field named after the domain field, with _DESC appended to the end of the field name.
Syntax
Parameter | Explanation | Data 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:
| 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
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")
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)