Modelbuilder - Generate Near Table

1123
1
01-22-2014 07:21 PM
MarkMcPherson1
New Contributor II
I am trying to find the distance between a mutual fund's headquarters  location and the stocks that it owns. For example, the mutual fund,  Union Investment (headquartered in Lincoln, Nebraska) owns 48 stocks  throughout the USA.


  In ArcMap 10.2 (Info), I have to: - select by Attribute the individual fund from my Fund layer (e.g. Union Invst) - select by Attribute the stocks that are owned by Union Invst (in the Stock layer, under the FUND_FAM column) - use "Generate Near Table" which gives me the distance (Input=Stocks, Near=Funds).


  It works, however, I will need to do this 226 times, as that's how  many funds I have to do. I'd like to do this in Modelbuilder, but I need  help. I believe this is some kind of iterate function, but I do not  understand this very well.  I appreciate any advise.

[ATTACH=CONFIG]30738[/ATTACH][ATTACH=CONFIG]30739[/ATTACH][ATTACH=CONFIG]30740[/ATTACH]
Tags (2)
0 Kudos
1 Reply
by Anonymous User
Not applicable
Original User: leonardlluz

I am trying to find the distance between a mutual fund's headquarters  location and the stocks that it owns. For example, the mutual fund,  Union Investment (headquartered in Lincoln, Nebraska) owns 48 stocks  throughout the USA.


  In ArcMap 10.2 (Info), I have to: - select by Attribute the individual fund from my Fund layer (e.g. Union Invst) - select by Attribute the stocks that are owned by Union Invst (in the Stock layer, under the FUND_FAM column) - use "Generate Near Table" which gives me the distance (Input=Stocks, Near=Funds).


  It works, however, I will need to do this 226 times, as that's how  many funds I have to do. I'd like to do this in Modelbuilder, but I need  help. I believe this is some kind of iterate function, but I do not  understand this very well.  I appreciate any advise.

[ATTACH=CONFIG]30738[/ATTACH][ATTACH=CONFIG]30739[/ATTACH][ATTACH=CONFIG]30740[/ATTACH]


Hi Mark!

I may have something that may help you automate the generation of near tables for each of the 226. However, you will still need to clean the resulting tables since I can't find a way to limit the generation of tables to just the stocks owned by a specific fund. Here it is:

You may use the Feature Selection Iterator with your Fund layer as input -> connect the output (green) to the Generate Near Table Tool as input table -> Connect the Stock layer as Near Table -> In the output location, specify the geodatabase and use "%Value%" as name. This way, it will create near table for each feature in the Fund layer.

The catch is, the near table that will be created for each Fund layer feature will have all records from your Stock layer so you may still need to delete the stocks that are not owned by a specific fund. If only you have a key field to join the two tables, I believe we can automate the process of deleting the stocks not owned by a specific fund.

Well, this is just a suggestion of course. 🙂
0 Kudos