ScottChang25

ArcGIS10.0-PythonWindow:Make XY Event Layer-How to set Workspace Environment Setting?

Discussion created by ScottChang25 on Oct 10, 2012
Latest reply on Oct 16, 2012 by clthompson
Hi all,
I want to use the tutorials "Make XY Event Layer" example (stand-alone Python script) and Using environment settings in Python of ArcGIS 10.0 to create a 12-Point feature and its msd Map for my ArcGIS project.  The following is the stand-alone Python script of  "Make XY Event Layer" from the HELP of ArcGIS 10.0:
# MakeXYLayer.py
# Description: Creates an XY layer and exports it to a layer file

# import system modules 
import arcpy
from arcpy import env

# Set environment settings
env.workspace = "C:/data"
 
try:
    # Set the local variables
    in_Table = "firestations.dbf"
    x_coords = "POINT_X"
    y_coords = "POINT_Y"
    z_coords = "POINT_Z"
    out_Layer = "firestations_layer"
    saved_Layer = r"c:\output\firestations.lyr"
 
    # Set the spatial reference
    spRef = r"Coordinate Systems\Projected Coordinate Systems\Utm\Nad 1983\NAD 1983 UTM Zone 11N.prj"
 
    # Make the XY event layer...
    arcpy.MakeXYEventLayer_management(in_Table, x_coords, y_coords, out_Layer, spRef, z_coords)
 
    # Print the total rows
    print arcpy.GetCount_management(out_Layer)
 
    # Save to a layer file
    arcpy.SaveToLayerFile_management(out_Layer, saved_Layer)
 
except:
    # If an error occurred print the message to the screen
    print arcpy.GetMessages()

////////////////////////////////////////////////////////////////////////////
I made a csv file (ID, Lot_ID, x-coords, y-coords, z-coords) for my 12 points (saved as sc12points.xls and sc12points.csv) in my C:/TEMP/WritingGeometries/ folder. Also I have a geodatabase "BS_Test" in my C:/TEMP folder.  In  the Using environment settings in Python of ArcGIS 10.0, I saw env.workspace = "c:/St_Johns/data.gdb".  I know that I have to do/process the sc12points.csv file in the C:/TEMP/WritingGeometries to my C:/TEMP/BS_Test geodatabase - see the attached file.  But, (1) I have no ideas how to complete this process. (2) I have 2 more questions to ask: (2a) is in_Table = "sc12points.csv" right to use in my case? (2b) are x_coords = "POINT_X" and y_coords = "POINT_Y" right to use in my case? 

Please kindly help and advise.

Thanks,
Scott Chang

Outcomes