This is somewhat tricky, if you insist using Model Builder and much easier with Python. The problem you have similar to using Spatial Join tool's Join operator of Field Mapping (for more info, please see https://esriaustraliatechblog.wordpress.com/2015/06/22/spatial-joins-hidden-trick-or-how-to-transfer-attribute-values-in-a-one-to-many-relationship/). However you do not have geometries to spatially join. Therefore I have two suggestions (1) Making your table spatial and using Spatial Join to find overlapping attributes, and (2) Using Calculate Value tool of the model builder with help of some Python.
Making your table spatial and using spatial join:
This is a process to create overlapping project area features for each near feature (lakes).
- Use Make Query Table tool to find matching project areas features. Your table and your project areas feature class will be two inputs (make sure they are in the same workspace, e.g., in the same file GDB) and you need an expression like,
Near_Table.Project_Location = My_Project_Locations_Feature_Class.Project_Location
for matching.
- Use Spatial Join as explained in the link above. Basically, you need to add a new TEXT field with enough length (to make sure the concatenated lake names fit in), say Lake_Names_Collated, and by using Join operator add the Near_Lake_Name field from your near table as input field into the Field Map of Join Features. Match Option should be ARE_IDENTICAL_TO.
- Dissolve your Spatial_Join output by using Project_Location and Lake_Names_Collated as Dissolve Fields.
Using Calculate Value tool
The idea is to create a python dictionary and use it in Field Calculator. Be aware though there is a character length limit of 30,000 (see this post) if you have a quite large near table! Here is the snapshot of the model, pay attention to the Preconditions before and after the Calculate Value
- Create a python dictionary as string by using the code below in a Calculate Value tool:
Expression**:
name_dict("%My_Near_Table%")
Code Block:
def name_dict(fc):
a_dict = {}
for row in arcpy.SearchCursor(fc):
a_dict.setdefault(row.Project_Location, set()).add(row.Lake_Name)
return str(a_dict)
Use Summary Statistics tool to create a new table with your project locations to add concatenated values. Only parameter that you need to pay attention is the Case_Field, which should be pointing to Project_Location field. The Statistics_Field could be any of your fields.
Add a TEXT field to concatenate lake names
Use the PYTHON expression below to calculate this field:
', '.join(map( str, %output_value%[!Project_Location!]))
** The table name in between %s is an inline variable substitution