Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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
share|improve this question
    
XY_Event_Layer name is declared for both input table and feature layer. –  Ibe Apr 27 at 18:12

1 Answer 1

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")
share|improve this answer
    
XY_Event_Layer is not defined. It should be in quotes if you want to hard-code it into the commands. –  Aaron Apr 27 at 18:58
    
@Aaron: Thanks for pointing it. Updated! –  Ibe Apr 27 at 19:39
1  
I believe it should be in quotes in the copy features command too. –  Aaron Apr 27 at 20:07

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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