Select to view content in your preferred language

Spatial Joins for Lines & Polygons

258
10
a week ago
SaraJL
by
Frequent Contributor

Hello everyone!

I'm brainstorming a scenario and the best way to address it - I'm working with a professor that has a line file that needs a spatial join with a polygon layer. Easy enough, however, we're running into an issue (that I was expecting to happen) - many of the lines are overlapping with the polygon boundaries so I'm trying to reconcile that.

For example, I ran the intersect to see where the spots are where the line overlaps with the polygon boundary. A point represents every part of the line that zig zags over the polygon boundary. The polygon boundary is highlighted in pink and the line is purple:

SaraJL_0-1760033752920.png

If it was a typical situation, I would split the lines at the points, and then it would give me a little more accurate count if I ran the spatial join and where it is located with the polygon. But I know in this case, the overlapping lines are a bit of a sticking point.

Any recommendations? I need to create some type of join between the lines and polygons, but there isn't a common field in either dataset. There are also many lines over one polygon, and one line can stretch multiple polygons. Ideally, I need some kind of table where it's one polygon (census tract in this case) with an entry for each line. Or just some why to create a tie between the layers when they only share a spatial relationship and no shared attributes.

To be honest - I'm not sure if there is much I can do about it, there is probably going to be some type of margin of error, but just exploring possibilities.

Also, something that does not involved writing a script please!

Thank you!

0 Kudos
10 Replies
DavidSolari
MVP Regular Contributor

If you run an Intersect between the lines and the polygons it outputs multipart features, one for every combo of line and polygon intersection. If you select the longest line for each group of line IDs you can use the polygon ID for that feature as your answer. Summary Statistics + Join Field should get you there.

If "what polygon has the most overlap" doesn't answer your question you'll have to provide more details on what you're trying to get out of the analysis.

0 Kudos
RPGIS
by MVP Regular Contributor
MVP Regular Contributor

Hi @SaraJL,

Another option you can try is:

  1. Dissolve the line features by a common field value to create a single line/multi-part feature.
  2. Create a point feature using the centroid of the line.
  3. Spatial join the point feature to the polygon.
  4. Join the spatial joined point back the line feature using the IDs of the line feature.

This would be my recommendation but there are other ways to tackle this problem.

0 Kudos
SaraJL
by
Frequent Contributor

For Step 1 - would that remove the other attributes from the table and only preserve the one field that we would use to dissolve the line features?

0 Kudos
RhettZufelt
MVP Notable Contributor

I've had similar need, but in my case, most of my lines crossed the polygon instead of following it.

I used the Feature To Line tool with my line layer and the polygon layer as inputs with Preserve Attributes selected.

This creates a fc with all the lines, both polygon outlines and the input line fc data, split at the intersections, with attributes from each.

I then select all features in the output that have a null value for the copied over ID field from the lines.  This way, I'm selecting only the polygon boundaries (as they don't have that particular ID field) and then I delete them.  Then I delete the un-needed polygon attributes that were carried over to the lines.

This leaves me with an attributed copy of my line input data that is split at each of the polygon boundaries that I can use for my spatial join(s).  Have not run into it myself, but the Feature To Line tool has 'some' flagging/handling of coincident lines/boundaries as well.

Different scenario, but thought I'd put it up here as don't think that is what that tool was originally intended for.

R_

0 Kudos
D_Atkins
Regular Contributor

Setting aside the specific geoprocesses required, what is the goal?

If a line is 'approximately' coincident with a polygon boundary...

1. Should the line be counted as 'in' both polygons?
2. Should the line be given to 'one' of 'two' polygons? 
   2a. How might you prioritize this association (a polygon attribute, line attribute, etc)?
3. Should the line-on-bounds be ignored altogether?

I imagine the chosen geoprocessing steps would vary in any case.

 

0 Kudos
SaraJL
by
Frequent Contributor

The general scenario is that the census tract information needs to be transferred to the lines.

There aren't any shared attributes between the census tract polygons and the lines - the only relationship they share is that they are located in the same county.

If this helps - we don't have a set census tract dataset - so I've been experimenting with the US census tracts on ArcGIS Living Atlas AND 2025 census tract information from the US Census Bureau website. I get similar results using either dataset, so I'm fairly positive that the census tract layer doesn't matter.

I've tried some experiments with spatial joins - my latest experiment:

  • Using the Intersect tool to add points to the lines where they intersect with the polygons
  • Using the Split at Point tool to try and split the lines
  • Run the Spatial Join > one to many

That's getting me a little closer, but I'm now running into an issue where the Split at Point tool is not really splitting the lines correclty. For example:

  • The bottom highlighted line was split correctly between the polygons
  • For some reason, the top highlighted line was not split - the top highlighted line DOES have a point. So I'm not sure why the tool didn't register it as a line that needed to be split

SaraJL_0-1760450737200.png

0 Kudos
RhettZufelt
MVP Notable Contributor

Did you try the Feature to Line tool?

Don't have your data to test, but my testing splits all the lines exactly at the polygon boundary so that the one to many spatial join has a single match for each line segment.  It also retains all the attributes as well.

R_

0 Kudos
D_Atkins
Regular Contributor

So the real problem is: the tract boundaries are intentionally drawn along the road (or the road built on the bounds).  Splitting the lines as they criss-cross the boundaries is taking advantage of spurious precision in the geometry, and not resolving the methodological questions:

If a road is supposed to be approximately on the bounds, do you want that road to inherit attributes from the 'left' polygon, the 'right' polygon, or from both polygons?   Should the result be a summary of both 'coincident' polygons?

This question really needs resolved before tackling the geoprocessing -- otherwise, as your images show, determining which 'polygon' the 'road' belongs to is about the same as a random roll of data precision and map projection. 

---

As for the geoprocessing steps and tools: Intersect (Analysis)—ArcGIS Pro | Documentation should be all that's needed to split lines by polygons.  

Then, Spatial Join (Analysis)—ArcGIS Pro | Documentation to update each line segment with the polygon id below.  

If you're having trouble with these tools (or their results), I would consider a thorough review of your spatial references.

0 Kudos
SaraJL
by
Frequent Contributor

The main issue is that I'm troubleshooting this for a client, so I'm kind of the go-between! So I can't really answer all of your questions. Just doing with the client is saying they need to do and testing out different ideas 🙂

Personally, if this was my research project, I would reach back out to the data host and see if they could give additional information. Which I've done in other scenarios, and some people will do (depending on the department). I would also only really recommend using a spatial join for points. 

The client needs census tract IDs associated with the lines, but this is most likely a "many to many" relationship, which the spatial join doesn't do. But yes! All of your points that you have raised, I am aware of. Unfortunately, I can't make assumptions for them, only present a variety of scenarios and they can pick which one they are the most comfortable with.

0 Kudos