Select to view content in your preferred language

ArcGIS10.0-PythonWindow:Make XY Event Layer- .csv & WGS 1984: Errors 000622 & 000628?

6311
21
10-16-2012 04:23 AM
ScottChang
Deactivated User
Hi all,
In the Excel 2007, I created a .csv file of the XY-coordinates for 10 points of my sampling locations at Edgewood, Maryland - see the attached file.  In the Python Window of my ArcGIS 10.0, I executed the following Python script:
>>> # scMakeXYlayer.py   for 12 points  Just X- & Y-coord, but no Z-coord in the csv & the .py file
... # Description: Creates an XY layer and exports it to a layer file
... # Author: ESRI - modified by Scott Chang per Chris Thompson's New No-Z (Date:  16 Oct 2012)
... # import system modules 
... import arcpy
... from arcpy import env
... # Set environment settings
... env.workspace = 'C:\TEMP\BS_Test.gdb'
...  
... try:
...     # Set the local variables
...     # in_Table = "firestations.csv"
...     tb = r'C:\TEMP\WritingGeometries\APGriMMRP.csv'
...     xc = "X"
...     yc = "Y"
...     
...     out_Layer = "BHsWellLocations_layer"
...     saved_Layer = r"c:\TEMP\BHsWellLocations.lyr"
...  
...     # Set the spatial reference
...     # spRef = r"Coordinate Systems\Projected Coordinate Systems\Utm\Nad 1983\NAD 1983 UTM Zone 11N.prj"
...     spRef = r"Coordinate Systems\Geographic Coordinate System\World\WGS 1984" 
...  
...     # Make the XY event layer...
...     arcpy.MakeXYEventLayer_management(tb, xc, yc, out_Layer, spRef)
...  
...     # Print the total rows
...     print arcpy.GetCount_management(out_Layer)
...  
...     # Save to a layer file
...     arcpy.SaveToLayerFile_management(out_Layer, saved_Layer)
...  
... except:
...     # If an error occurred print the message to the screen
...     print arcpy.GetMessages()
... 
ERROR 000622: Failed to execute (Make XY Event Layer). Parameters are not valid.
ERROR 000628: Cannot set input into parameter spatial_reference.
>>> 


Please kindly help and advise me why I got these 2 errors and how to fix them.

Thanks,
Scott Chang
Tags (2)
0 Kudos
21 Replies
annesanta_maria2
Emerging Contributor
Hi all!
IF I wanted to run this same script across many tables with x y coordinates how would I go about doing that? I have to automate the process. I have the script set up as this
>>> import arcpy
>>> from arcpy import env
>>> env.workspace = "C:/Users/Anne/Desktop/Python/final"
>>> arcpy.ListTables()
[u'AB10_.dbf', u'AB11_.dbf', u'AB15_.dbf', u'CFHMS_.dbf', u'CFMHN_.dbf', u'FA_.dbf', u'HSFHome_.dbf', u'HSFVAN_.dbf', u'KF18_.dbf', u'KF1W_.dbf', u'LASA_.dbf', u'MB_HAck_.dbf', u'PCM10_.dbf', u'PMB28_.dbf', u'pmc9_.dbf', u'SHROCK_.dbf', u'simo09_.dbf', u'SIMO94_.dbf', u'SP150_.dbf', u'sp42_.dbf', u'T13East_.dbf', u'T13West_.dbf', u'TB53_.dbf', u'TB63_.dbf', u'WSFBOW_.dbf', u'WSFDALLAS_.dbf']
>>> tblist = arcpy.ListTables()
>>> tb = tblist
>>> xc = "Lat"
>>> yc = "long"
>>> out_layer = "pointlayer"
>>> saved_layer = r"C:/Users/Anne/Desktop/Python/final"
>>> spRef = r"Coordinate Systems\Geographic Coordinate System\World\WGS 1984"
>>> for tablelist in tblist:
...     arcpy.MakeXYEventLayer_management(tblist, xc, yc, out_layer, spRef)
...     print arcpy.GetCount_management(out_layer)
...    

And that is the error message I get.
Should I be doing something else to the table list?
I may be in the wrong place, but I really need help 🙂
Runtime error
Traceback (most recent call last):
  File "<string>", line 2, in <module>
  File "c:\program files (x86)\arcgis\desktop10.1\arcpy\arcpy\management.py", line 6348, in MakeXYEventLayer
    raise e
RuntimeError: Object: Error in executing tool
>>>
0 Kudos
XanderBakker
Esri Esteemed Contributor
Hi Anne,

The "Error 000622" is referring to invalid parameters for the tool. In this case due to the fact that you specify the list of tables in the MakeXYEventLayer tool, rather than the table itself. Please observe the code below:

tables = arcpy.ListTables()
for tbl in tables:
    arcpy.MakeXYEventLayer_management(tbl, xc, yc, out_layer, spRef)



  • "tables" is a variable with the list of tables found in the current workspace

  • then you do a for loop, accessing each table "tbl" in the list "tables"

  • specify the variable "tbl" (the single table) to be used in the MakeXYEventLayer tool


Another thing to remember is that you use your latitude as X-coord and you Longitude as Y-coord. This should be the other way around:

xc = "long"
yc = "Lat"


Kind regards,

Xander
0 Kudos