I have a multi-part road polyline FC. For the longest part of a given polyline, I want to use the line/part's midpoint to get the WARD_ID of the closest polygon (single-part polygon FC).
Is there a way to do that operation with geoprocessing tools?
License level = Advanced.
Thanks.
var id = $feature.ORIG_FID
var fs = $featureset
var all_line_parts = Filter(fs, "ORIG_FID = @ID")
if($feature.Shape_Length == Max(all_line_parts, "Shape_Length")) {
return 1
}
return 0
Find nearby polygon features
Just want to mention some alternative tools to use:
1. To get the longest part among the singleparts with the same ORIG_FID, you can use Summary Statistics with MAXIMUM option on Shape_Length, using ORIG_FID as the Case FIeld. Then Add Join back to the singlepart features via ORIG_FID.
2. Once the longest parts have been identified, you can use Feature Vertices To Point with "Midpoint" option to get the midpoints.
As you mentioned the overlaps and gaps, when a midpoint falls inside multiple (overlapping) polygons, Near may return the FID for one of them. Are you concerned about that?
I am curious about why the roads are in multipart to begin with and why you need to know the closest Ward polygons to each midpoint of the longest part. Would you mind giving a brief explanation on the real story with some screenshots if possible? Thanks. - Dan
Thanks Dan. Regarding your question, "Why are the roads multipart to begin with?"
Answer:
Some of the roads are multi-part due to situations like this:
The road's "Exclusive Right Turn" lane was deemed to be too short to be it's own asset. So it was merged into it's parent asset as a multipart feature:
(Here's an example photo, although not the same one from the screenshot above: https://i.stack.imgur.com/aiL7W.png)
That decision was made years ago by people other than me and is beyond my control. (It's not possible to change things at this point...there are too many existing dependencies. Splitting the multipart into two single parts would compromise any records that are related. Including an already-integrated work order management system.)
The other scenario is:
Multipart features were created by accident. The person who digitized the roads merged two lines together, but didn't realize that a multipart feature was created.
In that case, it might be possible to go back and convert the multiparts to single parts. But it would take a lot of work to review/fix any linear referencing events that are tied to the geometry/M-values of those roads.
I've submitted an idea about multiparts here: Prevent multi-part features.
Does that answer your first question?
I'll answer your second question about "Why you need to know the closest Ward polygons to each midpoint of the longest part?" in a separate comment. Cheers.
Thank you Bud for explaining the two scenarios for multipart features to be created.
For the mistakenly created multipart features, if you can select them by some attributes without selecting those "sliparound lanes", then you can run Multipart To Singlepart to make them singlepart, each carries ORIG_FID, followed by Unsplit Line using the ORIG_FID as the Dissolve Field to merge them without being multipart. Hopefully you can use the ORIG_FID to join with original features to transfer any lost attributes. It may be a hassle but necessary.