Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

As my title says, I am currently trying to make my (working) standalone script into an ArcGIS tool so I'm not the only person in my office that can use it. It essentially selects all the data within a specified location and copies it to a new geodatabase. Since replacing my old variables with sys.argv[#], new errors keep popping up. The following section of code is giving me problems right now:

out_folder_path_gdb = sys.argv[1]
out_name_gdb = sys.argv[2]
out_name_fc = "buffer_point"
geometry_type = "POINT"
has_m = "DISABLED"
has_z = "DISABLED"
sr = sys.argv[3]
fc = out_folder_path_gdb + "\\" + out_name_gdb + "\\" + out_name_fc
lyrlst = []

######################
# Create geodatabase #
######################

try:
    arcpy.CreateFileGDB_management(out_folder_path_gdb, out_name_gdb)
except:
    print "Geodatabase already exists."
    arcpy.AddIDMessage("Error", 12, out_name_gdb)
    sys.exit(0)

##########################
# Create point to buffer #
##########################

arcpy.env.overwriteOutput = True
arcpy.CreateFeatureclass_management(out_folder_path_gdb + "\\" + out_name_gdb, out_name_fc, geometry_type, "", has_m, has_z, sr)

############################################
# Sets given coordinates as a point object #
############################################

rowInserter = arcpy.InsertCursor(fc)
x = sys.argv[4]
y = sys.argv[5]
pointGeometry = arcpy.Point(x,y)

When running the tool within Arc, I get the following error: : Failed to execute. Parameters are not valid. ERROR 000732: Feature Class Location: Dataset C:\Documents and Settings\benoyn\Desktop\DaS GIS work\data_extraction_test\pleasepleaseplease does not exist or is not supported Failed to execute (CreateFeatureclass).

The only reason I can think of for this error is the spaces in "Documents and Settings". Thanks everyone!

share|improve this question
1  
Have you tried testing it in a location without spaces? Such as "C:\Temp"? –  Fezter Feb 16 '13 at 0:46
add comment

1 Answer 1

It appears the error is encountered on the line for CreateFeatureclass, that the location is bad:

C:\Documents and Settings\benoyn\Desktop\DaS GISwork\data_extraction_test\pleasepleaseplease

And this should have been a string made of: out_folder_path_gdb + "\" + out_name_gdb

Note that the end component of that string should have been a gdb and it appears it is not (pleasepleaseplease is not a gdb), so that's is what you need to check - I'd particularly look at what is happening where the gdb is created, with the out_name_gdb param...verify that it is created properly based on your other string params.

Also, not saying it won't work with sys.argv to fetch user input, but try to use arcpy.GetParameterAsText(0) and see if that works better (start indexing the 'get' variables from zero (0) -- confirm with some print statements that you're receiving those params properly - I usually form raw strings whereever possible on pathnames and make sure extensions get appended (the .gdb), i.e., r'\server\folder\subfolder\name.gdb\nameFC'

Hope that helps, Wayne

EDIT: Not sure if you have any '\' in your script, but if so, python trips -- you can instead use os.sep to combine path components or use the os.path.join technique.

share|improve this answer
    
That did the trick! Thanks, Wayne! –  user15236 Feb 22 '13 at 23:38
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.