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
  • XY_Event_Layer name is declared for both input table and feature layer. – Ibe Apr 27 '14 at 18:12
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")
  • XY_Event_Layer is not defined. It should be in quotes if you want to hard-code it into the commands. – Aaron Apr 27 '14 at 18:58
  • 1
    I believe it should be in quotes in the copy features command too. – Aaron Apr 27 '14 at 20:07

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.