Select to view content in your preferred language

Field Mapping for Batch Spatial Join in Model Builder

3653
3
06-08-2010 12:05 PM
MatthewToro
Deactivated User
In Model Builder, I've added a Spatial Join process.  I want to Spatial Join six separate point layers to a single polygon layer with match option of contains.

Because I want to Spatial Join all six point layers to the polygon layer at the same time, I've gone ahead and created a Variable from the Join Features of the Spatial Join tool.  In the newly created Variable, I can add all six separate point layers as a batch.

However, I'm interested in the number of points that fall into each polygon.  This is typically generated with a default [Join_Count] field when Spatial Join is executed.

Since I am interested in the count of six separate layers, I want six separate count fields.  Thus, I tried to modify the Field Map of the Join Features for the batch.  The default [Join_Count] field didn't show up in the Field Map -- fine.  But I did add the new fields in the Field Map, set their field Type (to Long Integer), set the length of those long integers, and set the Merge Rule to "Count".

Here's the problem: when I validate the model, my added "Count" fields (which, take the format: [I_1W], [I_2W], [I_3W], etc.) disappear. 

How can I add some count fields that correspond to the six separate spatial joins performed by this batch in Model Builder?
0 Kudos
3 Replies
IanKidner
New Contributor
Did you ever find a solution to this issue?  I'm also interested in this same process, and have tried something similar, but with unsuccessful results.  I created a model that had two processes per join, one being the spatial join, and a second that would delete extra attribute fields before moving onto the next spatial join. 

When I run it with only two spatial joins, the resulting shapefile produces 'count' fields with the correct values, however, when I run it with three or more spatial joins, the count fields values are incorrect.
0 Kudos
ColinMurray
Emerging Contributor
I would like to do the same thing: Get the count of the number of points within each individual grid square in my fishnet for a number of point files.
I've run into this problem a few times and never been able to figure it out. I would expect that if I I want to spatially join a number of layers to one target layer, I would get the fields: [join_count], [join_count1],[joint_count2]... in the layer that I'm sequentially joining. But the model never does this and ends with me being frustrated and having to do it in many separate batch processes.

One solution I'm trying right now is to do the spatial join. Then do an ordinary table join- original target layer to the spatial join output using a unique row ID. I then update the field in the target table with the [join_count] field in the output and then remove the table join. This seems to work, because I'm only ever dealing with one [join_count] field. I would think I could do this with as many point tables or selections as I need. It may also make for a cleaner, hassle free, end product since I never have to remove extraneous fields from the spatial join output table. I would like it to work using the model builder batch processing (stating that the variable contains a list of values) but have not been able to get it to work for some reason.
0 Kudos
DanRubado
New Contributor
I'm having the exact same problem in Model Builder. I need to do multiple spatial joins of different point layers to a single polygon layer to obtain counts. I've tried all of the suggestions in this forum and have been trying to find a solution for a few days with no luck. I'm pretty much at my wits end. Did anyone ever find a good way to do this?
0 Kudos