Building on a earlier asked question on this forum I would like to ask an additional question in getting the task done I asked here: Dividing polyline layer in clusters with specific requirements in ArcGIS for Desktop?.
To do some preparation for this task I would like create a script to divide my line layer in separated parts making a cluster if the links are connected. So, in the next picture I show an example of what I mean.
To get this done I created a spatial join 'one to many' and match option 'boundery touches'. So that creates a table with all values that are connected to each other. My Idea is to take the FID of the 'original table' (for example 0), and search that value in the 'join table' in the field 'Target_FID'. Then take the values from the JOIN_FID column in the same rows (47, 109, 111). And then search these values (47, 109, 111) again in the Target_FID' column and get the values from the JOIN_FID column in the same rows (not visible in the picture). And do this until I get a list of all the values (FIDs) which are connected to each other. Next step then is to assign the same value in a new column to all the FIDs in this list in the 'original table'. To visualize this:
If the list of FIDs which are connected to each other was for example (0,1,2,3,4,5 and 6) give this value 1. And so on for other list of FIDs which are connected giving them values 2,3,4 etc.... This should create clusters of the connected parts.
To get this done was thinking of creating a script using searchcursor and updatecursor. I searched on how to get it done with these options but I couldn't figure out how to do it for my typical situation. Also because I am new to using these options in scripts. So, I am wondering if using the search and update cursors is the right method to get this task done? And if yes does anyone have a idea how the python script should look like? Or if it is not the right method, does anyone have a better idea to get this task done? It should not be to difficult I would say, but just haven't found the right method yet.