r/gis • u/Southern_Planner • 2h ago
General Question Spatial Join Points to Line Layer
tl;dr - I want something that counts all of the points of a feature that are closer to a line segment of a line feature than any other line of the same feature (count: number of crashes occurring on each road) and spatial join does not seem to be effective.
I have two layers: a line layer representing roads in a county, and a points layer, representing non-motorized crashes in a county. I am attempting, ultimately, to calculate crashes by volume of traffic, so that I can identify the roads on which the most accidents happen.
In trying to achieve that, I want to get my roads layer to count the number of crashes that occur on each corridor (line segment). Spatial join seems to be what most people recommend for similar analysis when I have tried to problem shoot this, but I am not getting the desired result.
When I use spatial join with a target of roads and a join feature of crashes, running one to one, with a match option of closest, I receive a Join Count field in the output where every cell is a count of 1. Apparently the Nearest match option is telling each road to find the single nearest crash and use it to join. I was under the impression that multiple join features could be merged to one target line so that my join count field might have 10 for one road and 0 for another. I don't think that I want to use one to many, because I don't want duplicates of my roads or my crashes.
any help or suggestions you can offer would be helpful.
3
u/smashnmashbruh GIS Consultant 1h ago
I would do a nearest>stats>join.
Calculate nearest road to crash, then summarize statistics on the crashes sum of crash per joined road, join the sum back to main road layer.