0

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. enter image description here

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: join table original table

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.

0

If I'm understanding you correctly, and you're trying to assign IDs to any set of features that touch, there is a simpler way. Perform a Dissolve on your feature class and set the multi part option to single part. Then you can perform a Spatial Join, using your original feature class as your target feature class, and the result of your Dissolve as your join feature class. This will transfer the OIDs of your dissolved feature class to the output of your spatial join, while maintaining the geometry of your original feature class.

  • Seems like a good an easy alternative. But I have a problem with the Dissolve on single part. When I do that on the layer in above example it does not make 4 parts of it but 65. It seems to cut it off on places where vertices remain, mostly where three lines or more come together. Any idea how to deal with that? – epke Oct 29 '15 at 14:58
  • So, yes that is exactly what I want to do, assign IDs to any set of features that touch. But i am still not able to do this. Because the dissolve with single part option breaks it indeed on places where 3 or more features come together. – epke Oct 30 '15 at 8:39
  • I solved it now by first making a buffer around it and dissolve this one with single part, then I get 4 parts which I can do a spatial join on with the original layer. Thanks for getting me on the right track. – epke Oct 30 '15 at 9:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.