Create Feature Class (Data Management)

Summary

Creates an empty feature class in an ArcSDE, file geodatabase, or personal geodatabase; in a folder it creates a shapefile.

Usage

Syntax

CreateFeatureclass_management (out_path, out_name, {geometry_type}, {template}, {has_m}, {has_z}, {spatial_reference}, {config_keyword}, {spatial_grid_1}, {spatial_grid_2}, {spatial_grid_3})
ParameterExplanationData Type
out_path

The ArcSDE, file, or personal geodatabase, or the folder in which the output feature class will be created. This workspace must already exist.

Workspace; Feature Dataset
out_name

The name of the feature class to be created.

String
geometry_type
(Optional)

The geometry type of the feature class.

  • POINT
  • MULTIPOINT
  • POLYGON
  • POLYLINE
String
template
[template,...]
(Optional)

The feature class used as a template to define the attribute schema of the feature class.

Feature Layer
has_m
(Optional)

Determines if the feature class contains linear measurement values (m-values).

  • DISABLEDThe output feature class will not have m-values.
  • ENABLEDThe output feature class will have m-values.
  • SAME_AS_TEMPLATEThe output feature class will have m-values only if the Template has m-values.
String
has_z
(Optional)

Determines if the feature class contains elevation values (z-values).

  • DISABLEDThe output feature class will not have z-values.
  • ENABLEDThe output feature class will have z-values.
  • SAME_AS_TEMPLATEThe output feature class will have z-values only if the Template has z-values.
String
spatial_reference
(Optional)

The spatial reference of the output feature dataset. You can specify the spatial reference in several ways:

  • By entering the path to a .prj file, such as C:/workspace/watershed.prj.
  • By referencing a feature class or feature dataset whose spatial reference you want to apply, such as C:/workspace/myproject.gdb/landuse/grassland.
  • By defining a spatial reference object prior to using this tool, such as sr = arcpy.SpatialReference("C:/data/Africa/Carthage.prj"), which you then use as the spatial reference parameter.

NoteNote:

When you use a Template Feature Class its spatial reference is ignored.

Spatial Reference
config_keyword
(Optional)

The configuration keyword applies to ArcSDE data only. It determines the storage parameters of the database table.

String
spatial_grid_1
(Optional)

The Spatial Grid 1, 2, and 3 parameters are used to compute a spatial index and only apply 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. Since no features are written by this tool, the spatial index will be in an unbuilt state. The index will be built when features are written to the feature class such as by the Append tool or editing operations. 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

CreateFeatureclass Example (Python Window)

The following Python Window script demonstrates how to use the CreateFeatureclass function in immediate mode.

import arcpy
from arcpy import env

env.workspace = "C:/data"
arcpy.CreateFeatureclass_management("C:/output", "habitatareas.shp", "POLYGON", "study_quads.shp", "DISABLED", "DISABLED", "C:/workspace/landuse.shp")
CreateFeatureclass Example 2 (Stand-alone Python Script)

The following Python script demonstrates how to use the CreateFeatureclass function in a stand-alone script.

# Name: CreateFeatureclass_Example2.py
# Description: Create a feature class to store the gnatcatcher habitat zones

# Import system modules
import arcpy
from arcpy import env

# Set workspace
env.workspace = "C:/data"

# Set local variables
out_path = "C:/output"
out_name = "habitatareas.shp"
geometry_type = "POLYGON"
template = "study_quads.shp"
has_m = "DISABLED"
has_z = "DISABLED"

# Use Describe to get a SpatialReference object
spatial_reference = arcpy.Describe("C:/workspace/studyarea.shp").spatialReference

# Execute CreateFeatureclass
arcpy.CreateFeatureclass_management(out_path, out_name, geometry_type, template, has_m, has_z, spatial_reference)

Environments

Related Topics

Licensing Information

ArcView: Yes
ArcEditor: Yes
ArcInfo: Yes

10/27/2014