I'm a complete noob at arcpy.
I must do a college paper using arcpy. It’s a step by step thing and it takes much longer than expected J
I’ve got a question regarding the add join tool. From what I could find online, I need to make a feature layer to get the join working. I’ve achieved this, but always with a problem: I lose my feature name when converting it to a layer. Each new feature is named after the «joinFeaturesLyr» (adding a number) and not using the features in the database names. Is there a way to solve this? It’s been killing me for the las two days.
This is the part of the script I mentioned. I tried to use the for
arcpy.env.overwriteOutput = True arcpy.env.workspace = tmp_GDB #It's a gdb called tmp! #outputFcList = arcpy.ListFeatureClasses() #print outputFcList for joinFeatures in arcpy.ListFeatureClasses(): arcpy.MakeFeatureLayer_management(joinFeatures, "joinFeaturesLyr") print 'Executing' try: arcpy.AddJoin_management(in_layer_or_view="joinFeaturesLyr", in_field="MsLink_ODBC", join_table=catalogo, join_field="ligacao") except Exception as err: print(err.args[0]) print ‘Exporting' try: arcpy.FeatureClassToGeodatabase_conversion("joinFeaturesLyr", tmp_GDB) except: #arcpy.AddError('Script Error') print arcpy.GetMessages()
Thank you!
Solved! Go to Solution.
Solved by using arcpy.JoinField_management....... Thank you
As they say, a picture is worth 1,000 words, sometimes more. If you could provide a couple screenshots showing what you see and describing what you want/expect to see, it would be helpful.
Yes, Thank you for you swift answer. I've tried it with Describe. Same issue
I wanted to have the same name of the input join features after the join. The problem is that, to have a join, I need to use the arcpy.MakeFeatureLayer_management. I've been unable to give each layer the name of the original feature. The join works, but in the end, instead of having a feature named T121502_A_pol_Polygon (and son on), the join features that result from the script are named (in this case) i_name_join (and so on). Is there a way to change the cript in order to get that result?
What about: arcpy.MakeFeatureLayer_management(i.name, i.name + "_join")
I also tried it. But the problem remains. Maybe the picture isn't clear. The «i_name_join_*» features are the result of the script. The «T121502_**» are the input features. They are the ones de «describe» is getting. What I would want is to have in the end, if possible, is:
original inpuit feature name «T121502_A_pol_Polygon»; result of the script «T121502_A_pol_Polygon» and not what i'm getting - «i_name_join»
I'm about to give up and use the result as is 😞
Solved by using arcpy.JoinField_management....... Thank you