import arcpy arcpy.env.overwriteOutput = True from arcpy import env import os arcpy.env.workspace = r"C:\Project\Project.gdb" model_nodes = "model_nodes" spField="SP" dataTable = "DeltaWL" #create Feature Layer for input feature class arcpy.MakeFeatureLayer_management(model_nodes, "model_nodes_FL") #loop through possible classes and for each create TableView for sp in range(1,11): #range (1 to 10) whereClause = 'spField = ' + str(sp) tableViewName = "Delta_WL" +str(sp) #name is based on 'sp' iterator arcpy.MakeTableView_management(dataTable, tableViewName, whereClause) #join data from Table View with 'Add Join' tool #"KEEP_COMMON" parameter cause preserving only maching records arcpy.AddJoin_management("model_nodes_FL","ID", tableViewName, "Cell_ID","KEEP_COMMON") #save feature layer with joined data arcpy.CopyFeatures_management("model_nodes_FL", "model_nodes_joined"+str(sp)) #remove existing Join to allow make new join with new subset (the second parameter is join name, which is name of joined data table) arcpy.RemoveJoin_management("model_nodes_FL", "DeltaWL")
import arcgisscripting gp = arcgisscripting.create(9.3) gp.workspace = r"Z:\Work\AttrFromCSV_to_FC.gdb" csvDataTable = r"Z:\Work\AttrFromCSV_to_FC.gdb\CSVdata" #Create list of feature classes in current workspace #ASSUMPTION: feature class layers share part of name with SP value: eg. layer_1 for SP=1 fcLst = gp.ListFeatureClasses() #loop through possible classes and for each create TableView for sp in range(1,11): #range (1 to 10) whereClause = '"SP" = ' + str(sp) gp.MakeTableView_management(csvDataTable,"csv_" + str(sp), whereClause) #for corresponding feature class in workspace create Feature Layer fcName = "SamplePoints_" + str(sp) #name of input Feature Class if fcName in fcLst: inputFLName = "inputFC_" + str(sp) #name of temporary Feature Layer gp.MakeFeatureLayer_management(fcName, inputFLName) #join data from Table View with 'Add Join' tool #"KEEP_COMMON" parameter cause preserving only maching records gp.AddJoin_management(inputFLName,"ID", "csv_" + str(sp), "Cell_ID","KEEP_COMMON") #save feature layer with joined data gp.CopyFeatures_management(inputFLName, "Joined_"+fcName) print "Joined_" + fcName + " created"
I would try making a tableview with a where clause. Make a list of your where clauses or create them on the fly depending on the complexity. You may have to convert your data to a different table type first, I don't believe csv is directly supported for this tool.
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.