[GIS] Spatially join polygons (target) to polylines (join) on longest intersecting polyline

arcgis-10.2arcgis-desktopspatial-join

I am curious if I can, without having to write a python or an ArcObjects script, create a spatial join that will result in a polygon feature class containing the attributes of the LONGEST intersecting join polylines. The input polylines I have roughly correspond to the polygons to which I want to transfer the attributes. I've determined that it is almost always the longest intersecting polyline whose attribute I need to transfer into the polygon.

Currently, using the figure below as an example, the spatial join hits 3 polylines (join_count = 3 for this particular polygon) but instead of joining on the longest intersecting polyline it seems to choose the first one it encounters. (which is also contrary to what the tool's description says about the JOIN_ONE_TO_ONE operation which is suppose to aggregate the join features into the output feature. The description speaks of SUM merge rule in its example which I do not see in this particular tool as an option)

I am using INTERSECT because there is no suitable spatial relationship I can think of in this "polyline to polygon" situation. I understand what is going on but don't know whether a workaround exists. I just wish there would be another set sub-parameters allow me to control what happens when more than one join features exists; in this case selecting the longest polyline by default.

I am using ArcGIS 10.2.1 Standard.
enter image description here

Best Answer

Intersect is indeed the way to go. After intersecting your lines and polygons, you end up with a line feature class wth the attribute table of the polygons, the attribute table of the lines and the length of your new lines.

You can then use "summary statistics" based on to original line ID's in order to fin the maximum length.

Then you join by attribute this new table with the intersect result (based on line ID) and you can select by attribute the length that are equal to the maximum length per ID.

The selection gives you the ID's of the polygons with the largest overlap, which you can now use for joining the polygon attributes to the original lines.

Here is a second work around, looks nicer but not completely robust :

1) create lots of points on your lines (e.g. densify then feature to points).

2) spatial join the points and the polygons

3) use spatial join with the mode values (see field mapping for details)

Why not robust :The longest is not necessarily the most vertices (could be solved and very unlikely), their can be two modes and several lines could combine to yield