Select to view content in your preferred language

Make XY Event Layer  in Python Crashes But Not in Model Builder

4381
16
Jump to solution
01-21-2013 11:02 AM
AdamGuo
New Contributor II
Hi,

I am trying to automate a table (in geodatabase) with lat longs and convert it into a feature class. I first created the steps in model builder where it works fine. But when I export out into Python script and run it without any modifications to the script, it would fail and give me the error below.

ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000732: XY Table: Dataset C:\Spatial.mdb\WELLS does not exist or is not supported
Failed to execute (MakeXYEventLayer)

Any ideas?

Thank you!

I am running Win 7 64 bit 10.1 SP1 with Geoprocessing for SP1 updated as well.

[ATTACH=CONFIG]20937[/ATTACH]
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
T__WayneWhitley
Frequent Contributor
...sorry if a little off topic Adam -- I question your original statement:

"I am running Win 7 64 bit 10.1 SP1 with Geoprocessing for SP1 updated as well."

Did you install 64 bit background geoprocessing?  If so, you may be having trouble reading 32 bit apps...xls, mdb, etc.

If that's your trouble, see Kevin Hibma's comment here:

"If you have 64bit BG and want to execute against 32bit Python (32bit Desktop) because you're using pGDBs, force your script to run against 32bit..."
http://forums.arcgis.com/threads/70241-10.1-sp-1-and-32-64-bit-Python-versions?p=245700#post245700


Also this, if it applies to your situation:
http://blogs.esri.com/esri/arcgis/2012/10/31/announcing-64-bit-geoprocessing/


PS - Thanks to Caleb for that spatial reference info...think Adam will need that as well.

-Wayne

View solution in original post

0 Kudos
16 Replies
MathewCoyle
Frequent Contributor
Posting the code that prompted the crash would be helpful.
0 Kudos
AdamGuo
New Contributor II
Sorry, here's the code. It's a direct export from the model built.


# -*- coding: utf-8 -*-
# ---------------------------------------------------------------------------
# a.py
# Created on: 2013-01-21 15:09:24.00000
#   (generated by ArcGIS/ModelBuilder)
# Description: 
# ---------------------------------------------------------------------------

# Import arcpy module
import arcpy


# Local variables:
WELLS__2_ = "C:\\FoB Oil and Gas\\GoM\\GOM_Spatial.mdb\\WELLS"
WELLS__3_ = "C:\\FoB Oil and Gas\\GoM\\GOM_Spatial.mdb\\WELLS"
WELLS__4_ = "C:\\FoB Oil and Gas\\GoM\\3_Compare\\Compare.mdb\\WELLS"
WELLS_Layer = "WELLS_Layer"

# Process: Make XY Event Layer
arcpy.MakeXYEventLayer_management(WELLS__4_, "SURFACE_LONGITUDE", "SURFACE_LATITUDE", WELLS_Layer, "GEOGCS['GCS_North_American_1927',DATUM['D_North_American_1927',SPHEROID['Clarke_1866',6378206.4,294.9786982]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]];-400 -400 1000000000;-100000 10000;-100000 10000;8.98305509728916E-09;0.001;0.001;IsHighPrecision", "")

# Process: Feature Class to Feature Class
arcpy.FeatureClassToFeatureClass_conversion(WELLS_Layer, WELLS__3_, "Wells_Spatial", "", "API \"API\" true true false 12 Text 0 0 ,First,#,,API,-1,-1;WELL_NAME \"WELL_NAME\" true true false 255 Text 0 0 ,First,#,,WELL_NAME,-1,-1;WELL_NAME_SUFFIX \"WELL_NAME_SUFFIX\" true true false 8 Text 0 0 ,First,#,,WELL_NAME_SUFFIX,-1,-1;OPERATOR \"OPERATOR\" true true false 75 Text 0 0 ,First,#,,OPERATOR,-1,-1;BOTTOM_FIELD_NAME_CODE \"BOTTOM_FIELD_NAME_CODE\" true true false 8 Text 0 0 ,First,#,,BOTTOM_FIELD_NAME_CODE,-1,-1;SPUD_DATE \"SPUD_DATE\" true true false 255 Text 0 0 ,First,#,,SPUD_DATE,-1,-1;BOTTOM_LEASE_NUMBER \"BOTTOM_LEASE_NUMBER\" true true false 10 Text 0 0 ,First,#,,BOTTOM_LEASE_NUMBER,-1,-1;RKB_ELEVATION \"RKB_ELEVATION\" true true false 8 Double 0 0 ,First,#,,RKB_ELEVATION,-1,-1;BH_TOTAL_MD \"BH_TOTAL_MD\" true true false 8 Double 0 0 ,First,#,,BH_TOTAL_MD,-1,-1;TVD \"TVD\" true true false 8 Double 0 0 ,First,#,,TVD,-1,-1;SURFACE_NS_DISTANCE \"SURFACE_NS_DISTANCE\" true true false 8 Double 0 0 ,First,#,,SURFACE_NS_DISTANCE,-1,-1;SURFACE_NS_CODE \"SURFACE_NS_CODE\" true true false 1 Text 0 0 ,First,#,,SURFACE_NS_CODE,-1,-1;SURFACE_EW_DISTANCE \"SURFACE_EW_DISTANCE\" true true false 8 Double 0 0 ,First,#,,SURFACE_EW_DISTANCE,-1,-1;SURFACE_EW_CODE \"SURFACE_EW_CODE\" true true false 1 Text 0 0 ,First,#,,SURFACE_EW_CODE,-1,-1;SURFACE_BLOCK_NAME \"SURFACE_BLOCK_NAME\" true true false 255 Text 0 0 ,First,#,,SURFACE_BLOCK_NAME,-1,-1;BOTTOM_NS_DISTANCE \"BOTTOM_NS_DISTANCE\" true true false 8 Double 0 0 ,First,#,,BOTTOM_NS_DISTANCE,-1,-1;BOTTOM_NS_CODE \"BOTTOM_NS_CODE\" true true false 1 Text 0 0 ,First,#,,BOTTOM_NS_CODE,-1,-1;BOTTOM_EW_DISTANCE \"BOTTOM_EW_DISTANCE\" true true false 8 Double 0 0 ,First,#,,BOTTOM_EW_DISTANCE,-1,-1;BOTTOM_EW_CODE \"BOTTOM_EW_CODE\" true true false 1 Text 0 0 ,First,#,,BOTTOM_EW_CODE,-1,-1;BOTTOM_BLOCK_NAME \"BOTTOM_BLOCK_NAME\" true true false 255 Text 0 0 ,First,#,,BOTTOM_BLOCK_NAME,-1,-1;TOTAL_DEPTH_DATE \"TOTAL_DEPTH_DATE\" true true false 255 Text 0 0 ,First,#,,TOTAL_DEPTH_DATE,-1,-1;STATUS_DATE \"STATUS_DATE\" true true false 255 Text 0 0 ,First,#,,STATUS_DATE,-1,-1;TYPE_CODE \"TYPE_CODE\" true true false 1 Text 0 0 ,First,#,,TYPE_CODE,-1,-1;DISTRICT_CODE \"DISTRICT_CODE\" true true false 2 Text 0 0 ,First,#,,DISTRICT_CODE,-1,-1;STATUS_CODE \"STATUS_CODE\" true true false 3 Text 0 0 ,First,#,,STATUS_CODE,-1,-1;WATER_DEPTH \"WATER_DEPTH\" true true false 8 Double 0 0 ,First,#,,WATER_DEPTH,-1,-1;SURFACE_LONGITUDE \"SURFACE_LONGITUDE\" true true false 8 Double 0 0 ,First,#,,SURFACE_LONGITUDE,-1,-1;SURFACE_LATITUDE \"SURFACE_LATITUDE\" true true false 8 Double 0 0 ,First,#,,SURFACE_LATITUDE,-1,-1;BOTTOM_LONGITUDE \"BOTTOM_LONGITUDE\" true true false 8 Double 0 0 ,First,#,,BOTTOM_LONGITUDE,-1,-1;BOTTOM_LATITUDE \"BOTTOM_LATITUDE\" true true false 8 Double 0 0 ,First,#,,BOTTOM_LATITUDE,-1,-1;SURFACE_LEASE_NUMBER \"SURFACE_LEASE_NUMBER\" true true false 255 Text 0 0 ,First,#,,SURFACE_LEASE_NUMBER,-1,-1", "")

0 Kudos
MathewCoyle
Frequent Contributor
It's a direct export from the model built.


That's probably one of your problems. I'd first clean up your code so it is legible.

I also don't see any reference to the path from your error C:\Spatial.mdb\WELLS.
0 Kudos
AdamGuo
New Contributor II
Sorry, I am not all that well versed with Python. I am still learning the ins and outs thus the exporting to script from model builder.

The full error is here. I accidentally deleted the full path to the directory in the first post.

Traceback (most recent call last):
  File "C:\Users\guoax\Desktop\a.py", line 20, in <module>
    arcpy.MakeXYEventLayer_management(WELLS__4_, "SURFACE_LONGITUDE", "SURFACE_LATITUDE", WELLS_Layer, "GEOGCS['GCS_North_American_1927',DATUM['D_North_American_1927',SPHEROID['Clarke_1866',6378206.4,294.9786982]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]];-400 -400 1000000000;-100000 10000;-100000 10000;8.98305509728916E-09;0.001;0.001;IsHighPrecision", "")
  File "C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\management.py", line 6322, in MakeXYEventLayer
    raise e
ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000732: XY Table: Dataset C:\FoB Oil and Gas\GoM\3_Compare\Compare.mdb\WELLS does not exist or is not supported
Failed to execute (MakeXYEventLayer).

[ATTACH=CONFIG]20938[/ATTACH]
0 Kudos
MathewCoyle
Frequent Contributor
You need to set up a workspace to execute this outside ArcMap. The help has an example you can walk through to get an understanding of the MakeXYEventLayer tool. All the field mapping at the end of your fc2fc look unnecessary as well.
0 Kudos
AdamGuo
New Contributor II
I've modified the code, and added a workspace environment, but it is still failing on me.

ERROR 000622: Failed to execute (Make XY Event Layer). Parameters are not valid.
ERROR 000628: Cannot set input into parameter spatial_reference.

# Import arcpy module
import arcpy

# Set the workspace environment to local file geodatabase
arcpy.env.workspace = r"C:\FoB Oil and Gas\GoM\WorkSpace.gdb"

try:
    # Local variables:
    WELLS_1 = "C:\\FoB Oil and Gas\\GoM\\GOM_Spatial.mdb\\WELLS"
    tbl = "C:\\FoB Oil and Gas\\GoM\\3_Compare\\Compare.mdb\\WELLS"
    lyr = "WELLS_Layer"

    # Set the spatial reference
    spRef = r"Coordinate Systems\Geographic Coordinate Systems\North America\GCS_North_American_1927.prj"

    # Process: Make XY Event Layer
    arcpy.MakeXYEventLayer_management(tbl, "SURFACE_LONGITUDE", "SURFACE_LATITUDE", lyr, spRef, "")

    # Print the total rows
    print arcpy.GetCount_management(lyr)

except:
    print arcpy.GetMessages()
0 Kudos
MathewCoyle
Frequent Contributor
I guess the help may not have been updated for 10.1. Spatial references can be set using a spatial reference object. You can see this thread for details on a work around.
http://forums.arcgis.com/threads/64242-Path-to-.prj-files-in-ArcGIS-v10.1

You can also try creating it without a spatial reference for troubleshooting.
0 Kudos
AdamGuo
New Contributor II
I just tried w/o the spatial ref. I am still getting this parameters are not valid error. I even tried exporting the table out to an excel file and replace the path. Everything works fine inside either ArcMap or Model Builder, just not in Python..

Executing: MakeXYEventLayer "C:\FoB Oil and Gas\GoM\3_Compare\Compare.mdb\WELLS" SURFACE_LONGITUDE SURFACE_LATITUDE WELLS_Layer # #
Start Time: Mon Jan 21 17:29:38 2013
Failed to execute. Parameters are not valid.
ERROR 000732: XY Table: Dataset C:\FoB Oil and Gas\GoM\3_Compare\Compare.mdb\WELLS does not exist or is not supported
Failed to execute (MakeXYEventLayer).
Failed at Mon Jan 21 17:29:38 2013 (Elapsed Time: 0.00 seconds)

# Import arcpy module
import arcpy

# Set the workspace environment to local file geodatabase
arcpy.env.workspace = r"C:\FoB Oil and Gas\GoM\WorkSpace.gdb"

try:
    # Local variables:
    tbl = "C:\\FoB Oil and Gas\\GoM\\3_Compare\\Compare.mdb\\WELLS"
    lyr = "WELLS_Layer"

    # Process: Make XY Event Layer
    arcpy.MakeXYEventLayer_management(tbl, "SURFACE_LONGITUDE", "SURFACE_LATITUDE", lyr, "", "")

    # Print the total rows
    print arcpy.GetCount_management(lyr)

except:
    print arcpy.GetMessages()
0 Kudos
T__WayneWhitley
Frequent Contributor
Adam, I only suggest this to help speed up getting this problem solved and end your frustration -
If you can, also post a small sample of your table.  If it is small enough, zip and attach your mdb.  Any reason you aren't using a file gdb?
0 Kudos