"calculate field" output in ModelBuilder question

623
6
06-19-2012 04:56 PM
AmyKlug
Occasional Contributor III
HI, I have created a model that performs a spatial join between a point layer and a polygon layer (selecting points inside the polygons) and I want to see if their "name" fields match. So I added a field to the spatial join layer and used python code to populate the field with a "yes" if the fields match and "no" if they do not, points outside the polygons have a null. I would next like to select all "yes" values and remove them so I am left with a table containing only "no" and "null" values/points. The only problem is I can't figure out a way to this. I have tried "select layer by attributes" (will only accept output of "calculate field" as a precondition) and "make table query" (empty field values so can't make a query). if i run the model it creates a feature class after "calculate field" is performed but ModelBuilder does not seem to see this until the model has actually run. ideas? i  would like to do this on one step. 

attachment
0 Kudos
6 Replies
DanBoitshoko
New Contributor
Hi Amy,

Insert the "Make Table View" tool before the "select layer by attribute" tool.  Use  the "Copy Rows" tool to save your selection.


Regards,
Dan
0 Kudos
AmyKlug
Occasional Contributor III
i tried this but i still dont have any values for my fields when using the query builder in "select layer by attributes" ("get unique values" is empty for all fields). I even tried copying in a query into the expression window. ideas??????
0 Kudos
JonathanQuinn
Esri Notable Contributor
What about the Select tool?  Try using that tool following the Calculate Field output.  You can use an expression in the tool to satisfy a certain criteria, and features that fall in the criteria are exported to a new feature class.
0 Kudos
AmyKlug
Occasional Contributor III
What about the Select tool?  Try using that tool following the Calculate Field output.  You can use an expression in the tool to satisfy a certain criteria, and features that fall in the criteria are exported to a new feature class.


does not work either

I think the problem is that you can only use the select features if the layer has actually been created. I noticed that in the links below they add a precodition variable to the "select by attribute" tool but I don't undertand how they create the variable because they don't show what the data looks like/how they created it.


http://webhelp.esri.com/arcgisserver/9.3/java/index.htm#geoprocessing/gp_servi953844009.htm

on page 31 here: www.junipergis.com/index.php/download_file/-/view/62
0 Kudos
DanBoitshoko
New Contributor
i tried this but i still dont have any values for my fields when using the query builder in "select layer by attributes" ("get unique values" is empty for all fields). I even tried copying in a query into the expression window. ideas??????


Do you need to access the field values? Try this query :  "PointName" <> "PolyName" OR "Join_Count" =0. This will return all the points whose "name" field does not match the polygon "name" and also all the points that do not overlap any polygons.
0 Kudos
AmyKlug
Occasional Contributor III
I found that if I use "make feature layer" right after the spatial join and before adding and calculating field and then typing in a query even though there are no values it does work, and the query "PointName" <> "PolyName" OR "Join_Count" =0 worked great too but I could also type in the values from the calculated field even thought it was empty

EDIT: I did not need to use "select layer by attributes" or add/calculate field because "make feature layer" has a query option and worked with the above query 

Thanks Dan!
0 Kudos