How to create a unigue IDs to Near_Dist values

1488
14
Jump to solution
01-24-2012 08:55 AM
ABDALLAMOHAMED
Occasional Contributor
Hello all...I need to derive connectivity between  polygons, That is, to show connectivity between polygons of similar near distances.For example polygons with IDs 1, 3,6, 8 have the same near distance, and I can give all of them one unique ID, say 1, and then go to the next polygons with same near distances and do the same, and so on and so forth. Any help..appreciated..
Thanks!
ABDALLA
0 Kudos
1 Solution

Accepted Solutions
DanLee
by Esri Regular Contributor
Esri Regular Contributor
Sure. They are ModelBuilder-only tools, not in the toolboxes. You should be able to search the Help system by "iterators". Here I quote the description from the Help topic "Accessing iterators in ModelBuilder":

"There are two ways to access iterators in ModelBuilder: through the Insert menu or from the shortcut menu (right-click in open space in the model).

- Click Insert > Iterators and choose an iterator to add to the model.
- Right-click in open space in the model, click Iterators, then choose the iterator to add to the model."

Hope you find them helpful.

View solution in original post

0 Kudos
14 Replies
DanLee
by Esri Regular Contributor
Esri Regular Contributor
To classify or group the features based on the NEAR_DIST values. You can try the following approaches:
 
Approach 1 �?? using Dissolve to group features:
1.        Run Dissolve tool with the NEAR_DIST as the Dissolve Field and the �??Create multipart features�?� box checked. This should make all features with the same NEAR_DIST value into one multipart feature. The resulting FIDs would be the unique IDs you need.
2.        Then run Multipart To Singlepart tool to break the multipart features into singlepart, each carries the dissolved FID from above. I hope that polygons with holes won�??t be an issue (I am not sure if the inner hole will come out a filled polygon; please test).
 
Approach 2 �?? using Frequency to group features:
1.        Run Add Field tool to add a field, e.g. ConID (for connectivity IDs), for storing the unique IDs you will get later.
2.        Run Frequency tool with the NEAR_DIST as the Frequency Field. The resulting table contains ObjectID, Frequency (count), and NEAR_DIST fields. The ObjectIDs of this table would be the unique IDs you need.
3.        Then run Add Join (or go to the input layer and add a join) to join the input table with the Frequency table via the NEAR_DIST as the join field. Now you should see the ObjectIDs from the frequency table above.
4.        Run Calculate Field tool to calculate the ConID by the frequency ObjectID.
 
Note: I am not sure if any of the above approaches will end up the unique IDs in the same ascending order as the near distance. Hope that doesn�??t matter to your analysis.

Hope that works for you.
0 Kudos
ABDALLAMOHAMED
Occasional Contributor
Dan..Thanks for your response.. Here is the ouput on sample data using approach-2 (Frequency):
FID Shape Id NEAR_FID NEAR_DIST ConID Rowid FID FREQUENCY NEAR_DIST *
0 Polygon 0 2 1716.566324 1 4 0 1            1716.566324
1 Polygon 0 4 1656.804153 1 3 0 1            1656.804153
2 Polygon 0 4 551.543298 2 1 0 2             551.543298
3 Polygon 0 4 602.992525 1 2 0 1              602.992525
4 Polygon 0 2 551.543298 2 1 0 2               551.543298

I will post the out put from approach-1 in a second.Any comments on the above output??
Thanks!\
ABDALLA
0 Kudos
ABDALLAMOHAMED
Occasional Contributor
Here is the output using the Dissolve tool to group features:
FID Shape * NEAR_DIST ORIG_FID
0 Polygon 551.543298 0
1 Polygon 551.543298 0
2 Polygon 602.992525 1
3 Polygon 1656.804153 2
4 Polygon 1716.566324 3
0 Kudos
DanLee
by Esri Regular Contributor
Esri Regular Contributor
Dan..Thanks for your response.. Here is the ouput on sample data using approach-2 (Frequency):
FID Shape Id NEAR_FID NEAR_DIST ConID Rowid FID FREQUENCY NEAR_DIST *
0 Polygon 0 2 1716.566324 1 4 0 1            1716.566324
1 Polygon 0 4 1656.804153 1 3 0 1            1656.804153
2 Polygon 0 4 551.543298 2 1 0 2             551.543298
3 Polygon 0 4 602.992525 1 2 0 1              602.992525
4 Polygon 0 2 551.543298 2 1 0 2               551.543298

I will post the out put from approach-1 in a second.Any comments on the above output??
Thanks!\
ABDALLA


It seems the ConID should be calculated by the Rowid (from the Frequency result table), not by the FREQUENCY (which is a count).
0 Kudos
DanLee
by Esri Regular Contributor
Esri Regular Contributor
Here is the output using the Dissolve tool to group features:
FID Shape * NEAR_DIST ORIG_FID
0 Polygon 551.543298 0
1 Polygon 551.543298 0
2 Polygon 602.992525 1
3 Polygon 1656.804153 2
4 Polygon 1716.566324 3


This looks good.

Isn't this what you wanted?
0 Kudos
ABDALLAMOHAMED
Occasional Contributor
Dan..When I calculated the ConID  by the Rowid , I got the same value numbers as Rowid..Is that what you think is right? look at the output below:
FID Shape Id NEAR_FID NEAR_DIST ConID Rowid FID FREQUENCY NEAR_DIST *
0 Polygon 0 2 1716.566324 4 4 0 1 1716.566324
1 Polygon 0 4 1656.804153 3 3 0 1 1656.804153
2 Polygon 0 4 551.543298 1 1 0 2 551.543298
3 Polygon 0 4 602.992525 2 2 0 1 602.992525
4 Polygon 0 2 551.543298 1 1 0 2 551.543298

Do you think that would be a duplicate??
Thanks a lot..
ABDALLA
0 Kudos
DanLee
by Esri Regular Contributor
Esri Regular Contributor
Dan..When I calculated the ConID  by the Rowid , I got the same value numbers as Rowid..Is that what you think is right? look at the output below:
FID Shape Id NEAR_FID NEAR_DIST ConID Rowid FID FREQUENCY NEAR_DIST *
0 Polygon 0 2 1716.566324 4 4 0 1 1716.566324
1 Polygon 0 4 1656.804153 3 3 0 1 1656.804153
2 Polygon 0 4 551.543298 1 1 0 2 551.543298
3 Polygon 0 4 602.992525 2 2 0 1 602.992525
4 Polygon 0 2 551.543298 1 1 0 2 551.543298

Do you think that would be a duplicate??
Thanks a lot..
ABDALLA


I should have included a step 5 at the end of the Frequency approach:
5.  Run the Remove Join tool (or from the layer - Joins ... - Remove join) to remove the added join. All the joined fields will disappear; now you only have the ConID field, no more Rowid. The purpose of using Join is to temporarily get the Rowid field shown in the table so that you can transfer its values to ConID via Calculate Field.
0 Kudos
ABDALLAMOHAMED
Occasional Contributor
Dan..Both of the above approaches work great. Now I will appy them to my entire data and see the result of that..Hopefully the result will be consistent with the sample data..Because I have large data, the process is going to take at least two days to finish. I will let you know by then..

Thanks a lot.. Appreciated!
ABDALLA
0 Kudos
DanLee
by Esri Regular Contributor
Esri Regular Contributor
You are welcome. I am happy to hear that. Good luck with your project! 🙂
0 Kudos