[GIS] Can a feature class be stored as a shapefile

arcgis-desktoparcpyfeature-classpythonshapefile

This is a general question about how a feature class is stored or can be stored using python/arcpy.

Can a list of created points (a feature class) be saved as a shapefile or in a shapefile, or to create a new feature class do you have to create a gdb and then add the feature class to it, then ultimately convert this to a shapefile using ArcPy?

Best Answer

To put it really simply, a shapefile is a feature class that is not stored within a geodatabase. So you can use a tool like Conversion > Feature Class To Feature Class (or arcpy.FeatureClassToFeatureClass_conversion) and convert a feature class or layer to a shapefile.

Modifying the sample script from Feature Class to Feature Class Desktop Help slightly, here is an example of converting a feature class to a shapefile. This takes a feature class called buildings_point from a geodatabase C:\data\GreenvalleyDB.mdb\PublicBuildingsand outputs them to a shapefile postoffices.shp in the folder C:\output

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

# Import system modules
import arcpy

# Set environment settings
arcpy.env.workspace = "C:/data/GreenvalleyDB.mdb/PublicBuildings"

# Set local variables
inFeatures = "buildings_point"
outLocation = "C:/output"
outFeatureClass = "postoffices.shp"
expression = ""

# Execute FeatureClassToFeatureClass
arcpy.FeatureClassToFeatureClass_conversion(inFeatures, outLocation, outFeatureClass, expression)