A line counting question

Hi,

I have a definition that gives starting points and ending points in a city, and connects paths between them. Some of the paths naturally overlap one other on busy streets, and im looking to create a “heatmap” of which streets experience the greatest foot traffic as the result of the number of routes that share any given segment of roadway. Im looking for a way to count where curves have duplicate lines then color code the data it to show intensity. Ill attach a example of some of the curves im working with below.

Paths.gh (3.4 MB)

Any ideas?

:slight_smile:

General approach, this will work best with polylines; explode the polylines, then count number of overlapping segments. An overlapping segment can be counted by the “remove duplicate lines” components, which gives a list of duplicate curves as an output, or by comparing midpoints. Once you have the range of numbers for number of duplicate lines, map a color corresponding to the number onto each line segment. ‘remove duplicate lines’ can be slow for over 8,000 lines or so; so, start with a small test case while you are developing your script. A further refinement would be to explode the line segments, and then compare only segments in between certain nodes (intersections) i the roadways. The amount of calculation time that you save by method #2 will not make up for the time spent, unless your name is google, so use method #1.

If you divide all your path curves into lots of points by length (say one point every metre), then overlapping curves will result in more dense points. Then you can count the number of points per grid square, or use some other sampling method.

This doesn’t work, or at least Im doing it wrong. I tried curves> explode > removeduplicatelines

the result is the same exact number of lines I began with (no duplicates found). This and the fact that i don’t understand how to get the number of times each line segment is overlapped from this even if it had worked?

Paths1.gh (3.4 MB)

I thought of doing this but im looking to just get a clean color mapping of lines, not a square grid surface heatmap. Any thoughts?

If your lines are exactly identical rather than just somewhat overlapping, you can convert them all to their midpoints, then use point groups or cull duplicates or something to figure out the valence of all the segments.

I’m on an iPad now, can’t run the actual software…

flatten your input on ‘remove dup lines’.

once you have a list of unique lines, you can then look for the midpoints of all lines in the original set of line segments that are within a circle distance R, say 0.1 meters, of the unique midpoint, the number of midpoints that are within this distance is the number of overlapping lines at that point.

Or, conceptually David’s approach will work, divide each curve by length as David suggested every 1 or 0.25 meters, setup a 1 meter grid, then count the number of points that are within each grid space.

This is a great opportunity for you to learn Grasshopper.

BTW suggest you move your curves in Rhino towards the origin.

Another idea, after some thought: if you use “shatter intersection”, this will shatter the curves at their intersections. Then, the centroid of each curve, or midpoint of each line, and then check for dupiuates from there.

Clever stuff. Thank you for the help so far!

I was already fiddling with something could the shatter at intersections, but I cant get it to work right. Any pointers?

The rest of the definition works fine, ill attach that. The problem is, as you point out, that “explode” makes way too many segments, and the pointincurves cant handle all of it, and it basically freezesOverlaps.gh (3.4 MB)
. Breaking each curve at intersections only would be critical.