I am using ArcGIS Desktop 9.3.
What I am looking to do is create a file geodatabase and add a feature class directly into that file geodatabase, as opposed to creating a feature class outside the file geodatabase and then importing it into the file geodatabase. The reason I need to be able to create the feature class directly in a file geodatabase is because I need to have attribute table columns that are nullable, whereas if I create a feature class outside the file geodatabase and then import it into the file geodatabase, nulls will not be allowed. Please correct me if I am wrong. Currently, I am able to create the file geodatabase, but I can't add a feature class directly to the file geodatabase. The code I currently have is:
import os, arcgisscripting
gp = arcgisscripting.create(9.3)
gp.Overwriteoutput = 1
cwd = "C:\\Path\\To\\directory"
gp.workspace = cwd
gp.toolbox = "management"
number = '1'
fileGDB = "test_%s.gdb" % number
shpFile = "file_%s.shp" % number
gp.CreateFileGDB(cwd, fileGDB)
gp.CreateFeatureclass(fileGDB, shpFile, "POINT", '#', '#', '#', '#')
gp.addfield ( shpFile, fieldName, "FLOAT", "20","20", "#", "#", "NULLABLE", "#", "#")
...the rest of my code here
Answer
I think your first problem is that you're appending ".shp" to your output geodatabase featureclass. Remove this and your problem may be solved.
...
....
shpFile = "file_%s" % number #--removed ".shp"
...
...the rest of your code here
No comments:
Post a Comment