Skip to main content

Hi,

 

I am to perform a spatial join between a line and a polygon. In some cases the line will be crossing polygon boundaries (there are no spaces between polygons). For these cases, I want to split the line, and find out which segment of the line is longer, then assign that polygon's attribute to the original line.

 

I've tried used the LineOnAreaOverlayer to split the lines, then using a Matcher to find 'duplicates' (lines that ended up getting split between polygons), and then the LengthCalculator. So I have something pretty close to the end product. I have a match_id value from the matcher so I know which lines belong to eachother (on top of a GlobalID that I'm using in the matcher). The issue I'm facing with this approach is that I do not know how to split these lines apart, or compare them against each other. Maybe I should use a sorter, then some type of filter to split every one feature into different features?

It sounds like you're almost there! After you've split the lines, and calculated their lengths, you should be able to sort them by some GlobalID and then length. Thereafter, use a sampler with group by = GlobalID and take the first one. The first one per group should then be the longest resulting line for each group/GlobalID


Sort by length in descending order then DuplicateFilter to only keep one instance of each line_id, the sorting means the feature you keep would be the longest. I'd also extract the line geometry before the LineOnAreaOverlayer so you can rebuild the line with its original geometry


Reply