1

I've made the XY Event Layer work through python script, but can't get it to work correctly as a python script tool on arc, asking for user input. Does anyone have any suggestions?

This is the script I am using on arc:

# Import arcpy module
import arcpy, sys, traceback
from arcpy import env

# Script arguments
Input_Table = arcpy.GetParameterAsText(0)
feat_output = arcpy.GetParameterAsText(1)

# Local variables:
XY_Event_Layer = Input_Table
Longitude_and_Latitude_Points = XY_Event_Layer
sr = arcpy.SpatialReference(104145)
feat_output = "long_lat.shp"

# Process: Make XY Event Layer
arcpy.MakeXYEventLayer_management(Input_Table, "longitude", "latitude", XY_Event_Layer, sr)

# Process: Copy Features
arcpy.CopyFeatures_management(XY_Event_Layer, Longitude_and_Latitude_Points, "", "0", "0", "0")

This is my parameter set up of the script tool properties:

input Table   -  Table View,
x coor     -     Field,
y coor     -     Field,
output feat.  -  Feature Layer
1
  • XY_Event_Layer name is declared for both input table and feature layer. Commented Apr 27, 2014 at 18:12

1 Answer 1

3

I have made edit to your code. Give it a try.

# Import arcpy module
import arcpy, sys, traceback
from arcpy import env

# Script arguments
Input_Table = arcpy.GetParameterAsText(0)
feat_output = arcpy.GetParameterAsText(1)

# Local variables:
sr = arcpy.SpatialReference(104145)
feat_output = "long_lat.shp"

# Process: Make XY Event Layer
arcpy.MakeXYEventLayer_management(Input_Table, "longitude", "latitude", "XY_Event_Layer", sr)

# Process: Copy Features
arcpy.CopyFeatures_management("XY_Event_Layer", feat_output, "", "0", "0", "0")
2
  • XY_Event_Layer is not defined. It should be in quotes if you want to hard-code it into the commands. Commented Apr 27, 2014 at 18:58
  • 1
    I believe it should be in quotes in the copy features command too. Commented Apr 27, 2014 at 20:07

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.