Hi there, Perhaps this is better in another mailing list, but I thought I'd give you guys a shot, as this is definitely the best GIS List I subscribe to. I'm having problems with an ArcGIS processing script I have written in Python. I'm using ArcGIS 9.0.
Basically, I have a tonne of .dbf files (comma separated), each containing the fields 'Cell', 'x_Coord', 'y_Coord'. I want to write a script which will take each on in turn, make an XY event layer from those lat/longs, and then export each one as a separate point shapefile. I am new to Python and have developed the following script by piecing together bits and pieces of code from other existing scripts. I'm trying to debbug it in PythonWin, and I get an error on the line: gp.AddToolbox("C:/Program/ArcGIS/ArcToolbox/Toolboxes/Data Management Tools.tbx")
The error is:
Unhandled exception while debugging... Traceback (most recent call last): File "C:Python25XY_to_pt_shp.py", line 18, in gp.AddToolbox("C:/Program/ArcGIS/ArcToolbox/Toolboxes/Data Management Tools.tbx") File "", line 2, in AddToolbox com_error: (-2147352567, 'Exception occurred.', (0, None, None, None, 0, -2147467259), None) Traceback (most recent call last): File "C:Python25Libsite-packagespythonwinpywinrameworkscriptutils.py", line 305, in RunScript debugger.run(codeObject, __main__.__dict__, start_stepping=1) File "C:Python25Libsite-packagespythonwinpywindebugger__init__.py", line 60, in run _GetCurrentDebugger().run(cmd, globals,locals, start_stepping) File "C:Python25Libsite-packagespythonwinpywindebuggerdebugger.py", line 631, in run exec cmd in globals, locals File "C:Python25XY_to_pt_shp.py", line 18, in gp.AddToolbox("C:/Program/ArcGIS/ArcToolbox/Toolboxes/Data Management Tools.tbx") File "", line 2, in AddToolbox com_error: (-2147352567, 'Exception occurred.', (0, None, None, None, 0, -2147467259), None)
Idon't really understand these error messages. Can anyone help me debug this? Would be much appreciated :)
Thanks! Louisa
# ---------------------------------------------------------------------------
#XY_to_pt_shp.py
# Created on: on 2007 04 25
# Created by Louisa Wood
# Module is designed to loop through a set of .dbf files in a folder C:/RNoutdbf, which contain lat/long information
# for selected cells in a ResNet solution.
# An XY event is generated for each .dbf file, then exported as a shapefile to folder C:/RNoutshp
#
# ---------------------------------------------------------------------------
# Import system modules
import sys, string, os, win32com.client
# Create the Geoprocessor object
gp = win32com.client.Dispatch("esriGeoprocessing.GpDispatch.1")
# Load required toolboxes...
gp.AddToolbox("C:/Program/ArcGIS/ArcToolbox/Toolboxes/Data Management Tools.tbx")
gp.AddToolbox("C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Conversion Tools.tbx")
#set input workspace
gp.workspace=("C:/RNoutdbf")
#set output workspace
outworkspace=("C:/RNoutshp")
try:
#Get a list of the dbf tables in the input folder
fcs=GP.ListTables()
#Loop through the list of feature classes
fcs.Reset()
fc=fcs.Next()
# define input table variables
in_Table = fc
in_x = "x_Coord"
in_y = "y_Coord"
out_layer = fc.split(".")[0]
sp_ref = "C:Program FilesArcGISCoordinate SystemsGeographic Coordinate SystemsWorldWGS 1984"
while fc:
# Process: Make XY Event Layer...
gp.MakeXYEventLayer_management(fc, in_x, in_y, out_layer, sp_ref)
# Process: Feature Class To Shapefile (multiple)...
gp.FeatureClassToShapefile_conversion(out_layer, outworkspace)
fc=fcs.Next()
except:
GP.AddMessage(GP.GetMessages(2))
print GP.GetMessages(2)
_______________________________________________ gislist mailing list gislist@lists.geocomm.com http://lists.geocomm.com/mailman/listinfo/gislist
_________________________________ This list is brought to you by The GeoCommunity http://www.geocomm.com/
|