I am trying to create a script tool to automate this process, eventually it will be used for batch processing but at the moment I can't even get test data to work. This is pretty basic at the moment, and I know it can be done through ArcGIS, but I would like to develop a python script for processing. My code is as below: It completes without error, but I am expecting the creation of a feature layer (even better would be a feature class with POINT geometry). I can't find or access the output of the SaveToLayerFile step.
#Import librariesimport arcpyimport osimport sysarcpy.env.overwriteOutput = True#Set workspacehome = arcpy.env.workspacearcpy.env.workspace = arcpy.GetParameterAsText(0)mxd = arcpy.mapping.MapDocument("Current")df = arcpy.mapping.ListDataFrames(mxd, "*")[0]#Create spatial reference objectprjFile = arcpy.GetParameterAsText(2)spatialRef = arcpy.SpatialReference(prjFile)arcpy.AddMessage('Setting Spatial Reference')#Set Excel Datasheet for MigrationTEST = arcpy.GetParameterAsText(1)try:# Process: Table to Table Conversion with destination variable FarmerTable = 'Farmers1' arcpy.AddMessage('Migrating Data...') arcpy.TableToTable_conversion (TEST, home, FarmerTable)except: arcpy.GetMessages()# Set local variablesin_layer = "FarmerLyr"out_layer = "FarmerLyr.lyr"out_layer0 = "FarmerLyr"try: #Make XY Events of each Farmer arcpy.AddMessage('Creating Features...') result = arcpy.MakeXYEventLayer_management(FarmerTable, "X", "Y", out_layer0, spatialRef, "") result.getOutput(0) = out_layer0 arcpy.AddMessage(arcpy.GetCount_management(out_layer0)) arcpy.AddMessage('Successfully Created Features') # Execute SaveToLayerFile arcpy.SaveToLayerFile_management(out_layer0, out_layer, "ABSOLUTE")except: print arcpy.GetMessages()
أكثر...
#Import librariesimport arcpyimport osimport sysarcpy.env.overwriteOutput = True#Set workspacehome = arcpy.env.workspacearcpy.env.workspace = arcpy.GetParameterAsText(0)mxd = arcpy.mapping.MapDocument("Current")df = arcpy.mapping.ListDataFrames(mxd, "*")[0]#Create spatial reference objectprjFile = arcpy.GetParameterAsText(2)spatialRef = arcpy.SpatialReference(prjFile)arcpy.AddMessage('Setting Spatial Reference')#Set Excel Datasheet for MigrationTEST = arcpy.GetParameterAsText(1)try:# Process: Table to Table Conversion with destination variable FarmerTable = 'Farmers1' arcpy.AddMessage('Migrating Data...') arcpy.TableToTable_conversion (TEST, home, FarmerTable)except: arcpy.GetMessages()# Set local variablesin_layer = "FarmerLyr"out_layer = "FarmerLyr.lyr"out_layer0 = "FarmerLyr"try: #Make XY Events of each Farmer arcpy.AddMessage('Creating Features...') result = arcpy.MakeXYEventLayer_management(FarmerTable, "X", "Y", out_layer0, spatialRef, "") result.getOutput(0) = out_layer0 arcpy.AddMessage(arcpy.GetCount_management(out_layer0)) arcpy.AddMessage('Successfully Created Features') # Execute SaveToLayerFile arcpy.SaveToLayerFile_management(out_layer0, out_layer, "ABSOLUTE")except: print arcpy.GetMessages()
أكثر...