Hello, in my problem i have used "sample tool" for a group of points, with the help of an iterator at modelbuilder and with the use of an inline variable. All i want to do is to join my tables with my points but i don't have a common column. So i created a tool to add a column to both of my groups (tables and point f.classes)
So what i did was that. I created two submodels which contain an iterator for tables (the first one) and (the second) an iterator for point fclasses and a connection to my tool which adds a common column to both of them wih the same values 0,1,2,3,4... so as to join them later, and i used an inline variable again for these submodels. My problem is that when i create a new model with these two submodels inside, although i can put their outputs in the boxes "Input table" & "Join Table" , there isn't any column to choose to join them at "Input Join Field" & "Output Join Field".
Please any help would be much appreciated. Thank you very much.
Solved! Go to Solution.
So I noticed that the XY data in your table are exactly the same spatial location as the points shapefile you gave me. If this is what you're trying to achieve, it's pretty easy:
1. Create XY events from your table (I used the spatial reference [projection] that your point shapefile was using)
2. Export the XY events to a shapefile, and you will have a points shapefile that has all the information that was included with the original table.
You should now have a properly projected shapefile with all the data you wanted in it in the first place.
# Import system modules import arcpy import os from arcpy import env arcpy.overwriteoutput = True # Set environment settings inWorkspace = arcpy.GetParameterAsText(0) inFC = arcpy.GetParameterAsText(1) outFC = arcpy.GetParameterAsText(2) data_type = "" fieldname = "FID_1" expression = 'getCalc()' codeblock = """id = -1 def getCalc(): global id id += 1 return id""" expression = 'getCalc()' # Execute CalculateField arcpy.CalculateField_management(inFC, fieldname, expression, "PYTHON_9.3", codeblock) arcpy.Copy_management(inFC, outFC, data_type)
This is the code of the tool i created. Below are the two submodels (at left ) i created and at the right the model i am trying to make. Thank you
1. Is the field 'FID_1' created somewhere else, or already exist?
2. If it does exist, what gets populated when you run the model? If you iterate the same tool over and over, your 'FID_1' will always be equal to 0, because that's what you're passing as an expression every time you run it. The id variable you have doesn't keep counting up every time the model iterates through the tool, it gets reset back to -1 when it's first run.
You're better off iterating through the feature classes and tables using a search cursor within the script itself, and then upping the value in a FOR loop for every feature.
what i am doing with my code is that i create a column FID and it gets the values 0,1,2,3,... for all the rows. I don't have any problem with that. It is being done correctly.
What exactly are you trying to join here anyways? It seems like you're just trying to add incremental values to a feature class and a table. Doesn't your table already have some form of meaningful information that you can use to join to the feature class instead of using a random number?
Unfortunately no, that is why i created these columns. My problem is when i am trying to get the group of tables and points from my submodels (outputs) in my model where join tool is. You can see the blank box. There it should be appearred all my fields but... Any suggestion?
So if I read you correctly, you have made sure that you have:
1. A feature class that has a field called FID_1 that has unique numbers from 0 -> whatever.
2. A table that has a field called FID_2 that has unique numbers from 0 -> whatever.
and they're not showing up as options on the Join Field tool. What happens when you try to join the outputs from the 2 sub-models to the Join Field tool? Do they populate the parameters for the tool? Are the fields different value types (ie one is a string, one is a int/float)?
Exactly. They are just not appeared as in the image above. Just a blank box. If i use an iterator for my points i can put it in sort tool and have my field and the same is for my tables. But i cannot have two iterators inside my model, that's why i created two submodels