Sunday 24 February 2019

arcpy - Creating feature class in file geodatabase in ArcGIS Desktop with arcgisscripting?


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

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...