>>> # scMakeXYlayer.py for 12 points Just X- & Y-coord, but no Z-coord in the csv & the .py file ... # Description: Creates an XY layer and exports it to a layer file ... # Author: ESRI - modified by Scott Chang per Chris Thompson's New No-Z (Date: 16 Oct 2012) ... # import system modules ... import arcpy ... from arcpy import env ... # Set environment settings ... env.workspace = 'C:\TEMP\BS_Test.gdb' ... ... try: ... # Set the local variables ... # in_Table = "firestations.csv" ... tb = r'C:\TEMP\WritingGeometries\APGriMMRP.csv' ... xc = "X" ... yc = "Y" ... ... out_Layer = "BHsWellLocations_layer" ... saved_Layer = r"c:\TEMP\BHsWellLocations.lyr" ... ... # Set the spatial reference ... # spRef = r"Coordinate Systems\Projected Coordinate Systems\Utm\Nad 1983\NAD 1983 UTM Zone 11N.prj" ... spRef = r"Coordinate Systems\Geographic Coordinate System\World\WGS 1984" ... ... # Make the XY event layer... ... arcpy.MakeXYEventLayer_management(tb, xc, yc, out_Layer, spRef) ... ... # 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() ... ERROR 000622: Failed to execute (Make XY Event Layer). Parameters are not valid. ERROR 000628: Cannot set input into parameter spatial_reference. >>>
>>> # scMakeXYlayer.py for 10 points at APG-RI-MMRP site ... # WGS 1984: X- & Y-coord, but no Z-coord in the csv & the .py file ... # Description: Creates an XY layer and exports it to a layer file ... # Author: ESRI - modified by Scott Chang per Chris Thompson's New No-Z (Date: 17 Oct 2012) ... # import system modules ... import arcpy ... from arcpy import env ... # Set environment settings ... env.workspace = 'C:\TEMP\BS_Test.gdb' ... ... try: ... # Set the local variables ... # in_Table = "firestations.csv" ... tb = r'C:\TEMP\WritingGeometries\ApgRImmrpWGS.csv' ... xc = "X" ... yc = "Y" ... ... out_Layer = "BHsWellEdgewood_layer" ... saved_Layer = r"c:\TEMP\BHsWellEdgewood.lyr" ... ... # Set the spatial reference ... # spRef = r"Coordinate Systems\Projected Coordinate Systems\Utm\Nad 1983\NAD 1983 UTM Zone 18N.prj" ... spRef = r"Coordinate Systems\Geographic Coordinate System\World\WGS 1984.prj" ... ... # Make the XY event layer... ... arcpy.MakeXYEventLayer_management(tb, xc, yc, out_Layer, spRef) ... ... # 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() ... ERROR 000622: Failed to execute (Make XY Event Layer). Parameters are not valid. ERROR 000628: Cannot set input into parameter spatial_reference. >>>
import arcpy from arcpy import env # Set environment settings #env.workspace = 'C:\TEMP\BS_Test.gdb' try: # Set the local variables # in_Table = "firestations.csv" tb = 'D:\\ApgRImmrpWGS.xls\\ApgRImmrpWGS$' xc = "X" yc = "Y" out_Layer = "BHsWellLocations_layer" saved_Layer = r"c:\Tmp\BHsWellLocations.shp" # Set the spatial reference # spRef = r"Coordinate Systems\Projected Coordinate Systems\Utm\Nad 1983\NAD 1983 UTM Zone 11N.prj" spRef = r"Coordinate Systems\Geographic Coordinate System\World\WGS 1984" # Make the XY event layer... arcpy.MakeXYEventLayer_management(tb, xc, yc, out_Layer, spRef) # Print the total rows print arcpy.GetCount_management(out_Layer) # Save to a layer file arcpy.CopyFeatures_management(out_Layer, saved_Layer) except: # If an error occurred print the message to the screen print arcpy.GetMessages()
>>> # scMakeXYlayer.py for 12 points Just X- & Y-coord, but no Z-coord in the csv & the .py file ... # Description: Creates an XY layer and uses CopyFeatures to save it to a layer file ... # Author: ESRI - modified by Scott Chang per Arkadiusz Matoszka (Date: 24 Oct 2012) ... # import system modules ... import arcpy ... from arcpy import env ... # Set environment settings ... # env.workspace = 'C:\TEMP\BS_Test.gdb' # New!!! ... ... try: ... # Set the local variables ... # in_Table = "firestations.csv" ... tb = 'C:\TEMP\WritingGeometries\arekAPGriMMRP.xls\APGriMMRP$' ... xc = "X" ... yc = "Y" ... ... out_Layer = "Pointlocations_layer" ... saved_Layer = r"c:\TEMP\arekAPGriMMRPLocations.shp" # not .layer!!! ... ... # Set the spatial reference ... spRef = r"Coordinate Systems\Projected Coordinate Systems\Utm\Nad 1983\NAD 1983 UTM Zone 11N.prj" ... # spRef = r"Coordinate Systems\Geographic Coordinate System\World\WGS 1984" ... ... # Make the XY event layer... ... arcpy.MakeXYEventLayer_management(tb, xc, yc, out_Layer, spRef) ... ... # Print the total rows ... print arcpy.GetCount_management(out_Layer) ... ... # Save to a layer file ... # arcpy.SaveToLayerFile_management(out_Layer, saved_Layer) ... arcpy.CopyFeatures_management(out_Layer, saved_Layer) # New!!! ... except: ... # If an error occurred print the message to the screen ... print arcpy.GetMessages() ... Executing: MakeXYEventLayer C:\TEMP\WritingGeometries rekAPGriMMRP.xls\APGriMMRP$ X Y Pointlocations_layer "PROJCS['NAD_1983_UTM_Zone_11N',GEOGCS['GCS_North_American_1983',DATUM['D_North_American_1983',SPHEROID['GRS_1980',6378137.0,298.257222101]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]],PROJECTION['Transverse_Mercator'],PARAMETER['False_Easting',500000.0],PARAMETER['False_Northing',0.0],PARAMETER['Central_Meridian',-117.0],PARAMETER['Scale_Factor',0.9996],PARAMETER['Latitude_Of_Origin',0.0],UNIT['Meter',1.0]];-5120900 -9998100 10000;-100000 10000;-100000 10000;0.001;0.001;0.001;IsHighPrecision" # Start Time: Wed Oct 24 08:12:45 2012 Failed to execute. Parameters are not valid. ERROR 000732: XY Table: Dataset C:\TEMP\WritingGeometries rekAPGriMMRP.xls\APGriMMRP$ does not exist or is not supported Failed to execute (MakeXYEventLayer). Failed at Wed Oct 24 08:12:45 2012 (Elapsed Time: 0.00 seconds) >>>
>>> tb = 'C:\TEMP\WritingGeometries\arekAPGriMMRP.xls\APGriMMRP$' >>> # which returns a faulty pathname because '\' is read as an escape character by Python >>> print tb C:\TEMP\WritingGeometriesrekAPGriMMRP.xls\APGriMMRP$
>>> # as given you by arekmatoszka: >>> tb = 'C:\\TEMP\\WritingGeometries\\arekAPGriMMRP.xls\\APGriMMRP$' >>> print tb C:\TEMP\WritingGeometries\arekAPGriMMRP.xls\APGriMMRP$ >>> # or do this: >>> tb = r'C:\TEMP\WritingGeometries\arekAPGriMMRP.xls\APGriMMRP$' >>> print tb C:\TEMP\WritingGeometries\arekAPGriMMRP.xls\APGriMMRP$
>>> # scMakeXYlayer.py for 10 points of ApgRImmrp: X-, Y-, and Z-coord in the xls & the .py file ... # Description: Creates an XY layer and uses CopyFeatures to save it to a layer file ... # Author: ESRI - modified by Scott Chang per Arkadiusz Matoszka & Wayne Whitley (Date: 31 Oct 2012) ... # import system modules ... import arcpy ... from arcpy import env ... # Set environment settings ... # env.workspace = r"C:\TEMP\BS_Test.gdb" # New!!! ... ... try: ... # Set the local variables ... # in_Table = "firestations.csv" ... tb = r"C:\TEMP\WritingGeometries\ApgRImmrpWGS.xls\ApgRImmrpWGS$" ... xc = "X" ... yc = "Y" ... zc = "Z" ... out_Layer = "Pointlocations_layer" ... saved_Layer = r"c:\TEMP\APGriMMRPBHsWell.shp" # not .layer!!! ... ... # Set the spatial reference ... spRef = r"Coordinate Systems\Projected Coordinate Systems\Utm\Nad 1983\NAD 1983 UTM Zone 11N.prj" ... # spRef = r"Coordinate Systems\Geographic Coordinate System\World\WGS 1984" ... ... # Make the XY event layer... ... arcpy.MakeXYEventLayer_management(tb, xc, yc, out_Layer, spRef) ... ... # Print the total rows ... print arcpy.GetCount_management(out_Layer) ... ... # Save to a layer file ... # arcpy.SaveToLayerFile_management(out_Layer, saved_Layer) ... arcpy.CopyFeatures_management(out_Layer, saved_Layer) # New!!! ... except: ... # If an error occurred print the message to the screen ... print arcpy.GetMessages() ... Executing: MakeXYEventLayer C:\TEMP\WritingGeometries\ApgRImmrpWGS.xls\ApgRImmrpWGS$ X Y Pointlocations_layer "PROJCS['NAD_1983_UTM_Zone_11N',GEOGCS['GCS_North_American_1983',DATUM['D_North_American_1983',SPHEROID['GRS_1980',6378137.0,298.257222101]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]],PROJECTION['Transverse_Mercator'],PARAMETER['False_Easting',500000.0],PARAMETER['False_Northing',0.0],PARAMETER['Central_Meridian',-117.0],PARAMETER['Scale_Factor',0.9996],PARAMETER['Latitude_Of_Origin',0.0],UNIT['Meter',1.0]];-5120900 -9998100 10000;-100000 10000;-100000 10000;0.001;0.001;0.001;IsHighPrecision" # Start Time: Wed Oct 31 13:31:34 2012 Failed to execute. Parameters are not valid. ERROR 000725: Layer Name or Table View: Dataset Pointlocations_layer already exists. Failed to execute (MakeXYEventLayer). Failed at Wed Oct 31 13:31:34 2012 (Elapsed Time: 0.00 seconds) >>>
>>> # scMakeXYlayer.py for 10 points of ApgRImmrp: X-, Y-, and Z-coord in the xls & the .py file ... # Description: Creates an XY layer and uses CopyFeatures to save it to a layer file ... # Author: ESRI - modified by Scott Chang per Arkadiusz Matoszka & Wayne Whitley (Date: 31 Oct 2012) ... # import system modules ... import arcpy ... from arcpy import env ... # Set environment settings ... # env.workspace = r"C:\TEMP\BS_Test.gdb" # New!!! ... ... try: ... # Set the local variables ... # in_Table = "firestations.csv" ... tb = r"C:\TEMP\WritingGeometries\ApgRImmrpWGSxyz.xls\ApgRImmrpWGS$" ... xc = "X" ... yc = "Y" ... zc = "Z" ... out_Layer = "Pointlocations_layer" ... saved_Layer = r"c:\TEMP\APGriMMRPBHsWellZ.shp" # not .layer!!! ... ... # Set the spatial reference ... # spRef = r"Coordinate Systems\Projected Coordinate Systems\Utm\Nad 1983\NAD 1983 UTM Zone 11N.prj" ... spRef = r"Coordinate Systems\Geographic Coordinate System\World\WGS 1984" ... ... # Make the XY event layer... ... arcpy.MakeXYEventLayer_management(tb, xc, yc, zc, out_Layer, spRef) ... ... # Print the total rows ... print arcpy.GetCount_management(out_Layer) ... ... # Save to a layer file ... # arcpy.SaveToLayerFile_management(out_Layer, saved_Layer) ... arcpy.CopyFeatures_management(out_Layer, saved_Layer) # New!!! ... except: ... # If an error occurred print the message to the screen ... print arcpy.GetMessages() ... ERROR 000622: Failed to execute (Make XY Event Layer). Parameters are not valid. ERROR 000628: Cannot set input into parameter spatial_reference. >>>