adding feature class to file gdb

920
4
03-19-2012 06:41 AM
JohnWilson2
New Contributor
I have created a file .gdb and am trying to add feature class to it.  I do not have a template feature class to use, what do I put in the space for template in my code?
Tags (2)
0 Kudos
4 Replies
JakeSkinner
Esri Esteemed Contributor
Hi John,

You do not have to place anything for the template.  This parameter is optional and can be skipped using "".  Ex:

arcpy.CreateFeatureclass_management("C:/output", "habitatareas.shp", "POLYGON", "", "DISABLED", "DISABLED", "C:/workspace/watershed.prj.")

http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//00170000002p000000
0 Kudos
JohnWilson2
New Contributor
ok well I tried that and I'm getting an error message that says the name contains invalid characters. I do not have spatial reference either and I am not sure what to put for it because I do not have any other feature classes in the .gdb I created. I would like to use NAD_1983_UTM_Zone_16N since the feature class will contain data from MS. how do I add a predefined spatial reference?  The final code will be used to import a text file of weather data.
0 Kudos
CoryMacNeil1
Occasional Contributor II
Hi John,

There are certain rules to creating a feature class regarding its naming convention:
Additional rules

�?�Names must begin with a letter, not a number or special character such as an asterisk (*) or percent sign (%).
�?�Names should not contain spaces.
If you have a two-part name for your table or feature class, connect the words with an underscore (_), for example, garbage_routes.

�?�Names should not contain reserved words, such as select or add.
Consult your DBMS documentation for additional reserved words.

�?�The length of feature class and table names depends on the underlying database. The maximum name length for File geodatabase feature classes is 160 characters. Be sure to consult your DBMS documentation for maximum name lengths.
Link

In regards to adding a spatial reference to a feature class that you created, it is normally done during the process of creating the feature class.  It is the second screen after you have indicated the name and type of feature class --> Click Next --> Go to Projected Coordinate Systems and expand list --> expand UTM --> expand NAD 1983 -->  choose NAD 1983 UTM Zone 16N --> next and carry on by adding in the attribute field names and types.  If you have an existing feature class with no spatial reference you can use the Define Projection tool in the toolbox.

A question for you.  If your data is stored in a Microsoft Access DB, you can add that table to your map document and then use the Add X/Y Data to create an event of all your points (assuming you have X,Y coordinates for your weather data).  Then right-click on that event layer in the Table of Contents and export the data out to a feature class in a file geodatabase.  I think that would be much easier.

I hope this helps.
0 Kudos
JakeSkinner
Esri Esteemed Contributor
Here is an example on how to add your coordinate system using python:

arcpy.CreateFeatureclass_management(r"C:\temp\python\test.gdb", "parcels", "POLYGON", "", "", "",
                                    "Coordinate Systems\Projected Coordinate Systems\UTM\NAD 1983\NAD 1983 UTM Zone 16N.prj")


A trick I do is find the coordinate system in ArcCatalog under 'Coordinate Systems', select it and then copy path from the 'Location' toolbar.
0 Kudos