3

I have a feature class containing road polylines which has to be dissolved by some fields. But recently noticed that if some road has same atrtributes but different directions, Dissolve tool doesn't keep it separate.

enter image description here

Tried Unsplit lines parameter but it didn't help. Any thougths how to keep lines like that untouched?

6
  • Not sure but I think that if the lines have different directions, after dissolve you get a multipart line (and a single part for same direction lines). If that hold true you could just use explode multipart after dissolving....
    – J.R
    Commented Jun 8, 2018 at 13:00
  • 2
    You could add a bearing field, round/reclass it into four (or less/more) classes N-S-E-W and use as one of the dissolve fields.
    – Bera
    Commented Jun 8, 2018 at 13:03
  • @J.R I usually set "Single part" parameter in order not to convert result to single parts. Multipart didn't help as well... Commented Jun 8, 2018 at 13:09
  • @BERA Might be a solution but probably when a road is circular, Dissolve will give too many separated lines Commented Jun 8, 2018 at 13:11
  • I had the same problem many years ago, the only solution I could find was to write my own dissolve routine in C#. The logic can be implemented in python.. add a field (unId) iterate the lines selecting by location using a buffer of the toPoint, exclude the current feature, test the buffer.Contains selected line fromPoint and recurse with that lines' toPoint, when you reach the end (no more lines going the same direction) set the unId of the features to the current value and increment.. as you move through the lines skip anything that has an unId then dissolve using unId as a parameter. Commented Jun 8, 2018 at 13:17

1 Answer 1

2

The solution requires several operations to do this using geoprocessing.

  1. For my approach I have calculated a fixed ID field with values that match the ObjectID of the original lines and the From and To coordinates of all of my original lines into two string fields using a format of "{#######.####}{#######.####}" in each (using zero padding so that both coordinate values have a known character length).

  2. I would do the dissolve as you normally do.

  3. In the dissolve output, calculate a new long field and two double fields to be equal to the ObjectID and the From and To measure values equal to 0 and the line length respectively.

  4. Use the Create Route tool with the dissovle output using the long field you calculated as the Route_ID and the Two Field option using the From and To measure fields you calculated to ensure the orientation is preserved. Be sure to set up the environment variables for your M tolerances and resolution before running the tool to get consistent results and you may have to experiment a little to get the best results.

  5. Use the Locate Feature Along Route tool to create events of the original lines overlaying the routes created in step 4.

  6. Use the Make Route Event Layer to create line route event features of the output of number 5 on the routes you created in number 4.

  7. Export the route events created in step 6 from the table of contents to generate an actual line feature class rather than events to improve performance on the next step.

  8. In a new pair of From and To end coordinate string fields calculate the end points of the lines created in step 7 using the "{#######.####}{#######.####}" format.

You can then compare the end coordinates of the original lines to the new lines to identify the set of original lines that matched the orientation of the dissovle and the set that did not. Since I use a coordinate format that is easy to parse it is possible to Substring and Cast to do SQL selections and comparisons that deal with inexact matches. You can use the IDs from step 1 that will be in the final output to select the original lines for each set and attribute them to keep them separate in a new dissolve.

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.