My ultimate goal is to automate kernel density analysis on xy data from a table. I am trying to learn Python but I am very new. I built a simple model to take table data and display xy data. When I attempt to export the model as a Python script, the script fails. I do not have a programming background but I have programmers available to me. Any help or advice would be greatly appreciated.

# -*- coding: utf-8 -*-
# ---------------------------------------------------------------------------
# test.py
# Created on: 2014-02-12 13:14:37.00000
#   (generated by ArcGIS/ModelBuilder)
# Description: 
# ---------------------------------------------------------------------------

# Import arcpy module
import arcpy

# Local variables:
Input_Table = "C:\\Users\\cbriglia\\Desktop\\GIS\\Worksheets\\accidents_jan_2013.xls\\Sheet1$"
Sheet1__Layer = "Sheet1$_Layer"
Ouput_Feature_Class = "C:\\Users\\cbriglia\\Desktop\\GIS\\Shapefiles\\acc_jan_2013_builder.shp"

# Process: Make XY Event Layer
arcpy.MakeXYEventLayer_management(Input_Table, "longitude", "latitude", Sheet1__Layer, "GEOGCS['GCS_North_American_1983_CSRS',DATUM['D_North_American_1983_CSRS',SPHEROID['GRS_1980',6378137.0,298.257222101]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]];-400 -400 1000000000;-100000 10000;-100000 10000;8.98315284119521E-09;0.001;0.001;IsHighPrecision", "")

# Process: Copy Features
arcpy.CopyFeatures_management(Sheet1__Layer, Ouput_Feature_Class, "", "0", "0", "0")

Runtime error Traceback (most recent call last): File "", line 19, in File "c:\program files (x86)\arcgis\desktop10.1\arcpy\arcpy\management.py", line 6348, in MakeXYEventLayer raise e ExecuteError: ERROR 000582: Error occurred during execution.

  • 1
    I note you are using Evil Excel, the source of many problems! Is your first row the field headers? Remove all unusually characters, don't start a field with a number and skim through your data to make sure there are no mysterious blank rows or a change in data type. – Hornbydd Feb 12 '14 at 19:01
  • 1
    I also, just personally, would change the name of the Sheet1__Layer from "Sheet1$_Layer" to Sheet1_Layer or just anything without a special character. As the comment above notes, ArcGIS can be picky about special characters, so minimize their use as much as possible. – John Feb 12 '14 at 19:06
  • Thank you. Would you recommend going with CSV? – Chris Feb 12 '14 at 19:37
  • I believe it was the special character. It works now. – Chris Feb 12 '14 at 20:06
  • 3
    @Chris, you should go ahead and leave a detailed answer of what you found so that future readers of this question will not have to go through the same struggle as you. In a couple of days, you can mark the "checkmark" next to you answer as "Accepted" to close out this question. Glad you found your own solution! – RyanDalton Feb 12 '14 at 20:21

I realized that there can be no spaces or special characters in output file names when using Python. I removed the special character and the script worked.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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