Select to view content in your preferred language

Collapse 2 Lines Into 1 Centerline

2117
2
11-21-2022 10:06 AM
Status: Open
Labels (1)
JeffreyWilkerson
Frequent Contributor

We have light rail ridership points that get generated when the cars stop at a station and people either get off (alight) or get on (board). This is supposed to occur next to a station, but due to irregularities in GPS locating they sometimes occur at a distance away from the station. In order to identify which station the records belong to, I developed a SQL Server procedure that (using SQL Server Spatial tools) determines the nearest station based on distance.

This works pretty well until you get to some stations that are really close,

RooseveltAndCentral.PNG

 

or where the Eastbound/Westbound lines actually share the same station.

50th Street Station, East and West Bound50th Street Station, East and West Bound

 

So we've come up with the idea that we should build polygons around the light rail stations to allow for points to be defined to the correct, or at least 'most' correct light rail station based on them being in a polygon, vs just the closest station. 

To build the polygons I was going to buffer the 2 light rail lines (Eastbound and Westbound) the outside by say 1/2 of a mile, and then determine the centerline between the 2 lines for something that would divide the 2 halves evenly.

I tried using the Merge Divided Roads in Pro. I added a field called 'Class' to the light rail routes and calculated them all to be '1'. Then I ran Merge Divided Roads and it returned the same routes that went into the command.

 

 

 

arcpy.cartography.MergeDividedRoads("LightRailLine", "Class", "1000 Feet", r"C:\Documents_Me\Projects\Ridership\MyProject1\MyProject1.gdb\LightRailCenter", None, None, None)

 

 

 

 Not sure how to use this command I kept looking and came across the CollapseDualLinesToCenterline command for ArcMap. Not finding an equivalent for Pro, I fired up the ArcMap I still have on my desktop and within a minute I had the centerline I was looking for:

 Centerline.PNG

 

Not sure why it does some of the squiggles it does, as the existing routes don't seem to deviate that much, but at least it's a start in getting something to work with. Now I can get on with creating polygons around each station.

I can see a Collapse2LinesTo1Centerline command in Pro as being helpful for this specific situation, but also others such as showing the center of a river based on its 2 banks, or merging 2 or more roads (different LIDAR/GPS tracks?) into 1 centerline, or finding the line between 2 distant parcels. 

When I was with the Dept. of Transportation, we had an awesome developer, Tom Tyndall that came up with a way to show multiple fence surveys next to roads by buffering each survey from the road (or last survey) and creating offset lines with survey attributes. I've often wondered if something similar could be used to generate transit lines within an urban area, ones that were offset to show better, but didn't overlap other route lines. Maybe a centerline generation tool would help in that instance as well.

 Thanks for listening.

I have 2 lines denoting the path of light rail trains through an urban area. I am interested in segmenti

2 Comments
wayfaringrob

Have you tried the remove overlap GP tool? Remove Overlap (multiple) (Analysis)—ArcGIS Pro | Documentation

 

VinceE
by

The way a lot of these "centerline" algorithms work is via Thiessen Polygons. I might try doing this with your problem here. Lots of third-party workarounds, but as described, you'll need an Advanced license I believe. This is all in Pro, by the way.

  1.  Create a copy of your rail lines, because this will destroy them during densification.
  2. Densify the copy of the rail lines. Do some testing, smaller densification values will increase "accuracy," but can really hinder processing time.
  3. Convert all (now dense) vertices to a point feature class.
  4. Run Thiessen Polygons on those points.
  5. Do some simple Dissolving, Merging, Feature to Line, etc. whatever you need to do to isolate that middle line.
  6. Ideally, script the above.

You can clearly see the center between the "rail" lines after the new polygons are created.

VinceE_1-1669236148957.png

 

And closer...

VinceE_2-1669236191418.png

I have no idea what algorithm was used in ArcMap, but I never had much luck with it. BUT, if you don't densify your input lines enough, you can get similarly choppy outputs using the method described above, so perhaps that is what is happening with their implementation (and your shown outputs).

I use a similar algorithm to get the centerlines for streams. See below. Second image on the far left shows an example where it doesn't always get things right.

VinceE_3-1669236458770.png

stream_centerline_2.png

Another good resource, created by user "tomdilts".

Polygon to Centerline Tool for ArcGIS - Overview