0

The below picture shows the table of a shapefile, including fields of TotalCT, and coordinates of the ends of the line. I want to merge the lines if they are adjacent and only keep the field of TotalCT.

I have no idea about the logical flow of this arcpy code.

Any suggestions?

enter image description here

1 Answer 1

3

You should be able to use the Dissolve tool (no need for ArcPy) which:

Aggregates features based on specified attributes.

In your case just use a single attribute (TotalCT).

It looks like this will result in a multipart feature so, if you need to get the parts that do not touch as separate features, try running Multipart to Singlepart as a second step:

Creates a feature class containing singlepart features generated by separating multipart input features.

Alternatively, a one step process that could do this is described in a comment by @MichaelMiles-Stimson (but he has made a later comment questioning the accuracy of that alternative):

Dissolve has a switch for 'Multipart' and 'Unsplit Lines' http://help.arcgis.com/EN/arcgisdesktop/10.0/help/index.html#//00170000005n000000 if you select 'no multipart' and 'unsplit lines' it should leave the unattached lines exactly as they are, only merging/dissolving lines that share a common endpoint - no need to run multipart to single.

6
  • I am sorry I didn't give the question clearly. In the table, not all lines are adjacent. Therefore, I have to check whether lines are adjacent and only merge those adjacent lines.
    – Tianxin Li
    Commented Sep 2, 2016 at 1:38
  • Also, the Dissolve gives me another idea that is can I dissolve all the line first, and then split the dissolved line to separate lines if they are not touching.
    – Tianxin Li
    Commented Sep 2, 2016 at 1:40
  • Really neat method! Works for my case.
    – Tianxin Li
    Commented Sep 2, 2016 at 1:59
  • 1
    Dissolve has a switch for 'Multipart' and 'Unsplit Lines' help.arcgis.com/EN/arcgisdesktop/10.0/help/index.html#//… if you select 'no multipart' and 'unsplit lines' it should leave the unattached lines exactly as they are, only merging/dissolving lines that share a common endpoint - no need to run multipart to single. Commented Sep 2, 2016 at 2:51
  • @MichaelMiles-Stimson I forgot about that but have now incorporated it into my answer. Always feel free to add another answer or to edit mine when you see something like this.
    – PolyGeo
    Commented Sep 2, 2016 at 3:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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