I have a set of polygons with polylines running through them. I am trying to assign the polylines the polygon ID that they pass through the most. I have already split the polylines to the polygon boundaries, merged the individual shapefiles together keeping seperate features and joined them spatially to the polygons to give them the polygon IDs.
The issue I now face is to dissolve the features based on their polyline IDs while making the features keep the attributes of the section that is longest in a polygon. For example, if 60m of a polyline falls in polygon 1 and 40m of it falls in polygon 2, the rejoined line keeps the attributes of the section in polygon 1. There may be any number of features to merge.
Notable Condition: Some polylines may have more length outside of a polygon than inside. For those lines, I need the line to keep the attributes of the one that passes through a polygon. For example, if 5m of the line passes through polygon 1 and 95m of it pass through empty space, the merged attributes should reflect the line passing through the polygon
Here is the basic logic that I believe will work. I am just not sure how to code it into python or if there are tools that can accomplish what I am trying to do.
Select two line features. When one line has lineid = 1 and the second has lineid = 1, check for polygon ids in both, if only one has a polygon id, merge based on the one with an id, if they both have polygon ids, compare the lengths and merge based on the one that is longest. Move on to the next feature.
I am not sure if they need to be compared one at a time or if the dissolve tool or something else incorporates this kind of code. Thoughts?
I am using ArcGIS 10.0