Geographic Information Systems Asked by zwornik on May 2, 2021
I am using FME transformer PointOnLineOverlayer to split a line (formed by Road Elements) by Point (Traffic Sign), to do some further processing on split lines. In case there is more than one point on line, my split line is not as expected i.e. for each point it does not create 2 lines, with each line having one end at Point and second end at the end of line.
The attached image should illustrate my problem. Green and red dots represent 2 points (Traffic Signs) on a line (Road). After splitting by FME I am getting 3 lines (double arrowed Black lines) for my line, while I want to get lines as drawn in red and green for each of my points.
Is there any setting in FME transformer to make splitting from point to end of input line?
This is a tough one. The issue here is that you really want to make a copy of of the input lines for every point, so that you consider each point with its neighbouring line separate from any other point (even those that may be near the very same line).
Unfortunately there is no setting on the PointOnLineOverlayer to do precisely what you want. However, this transformer does have a group by, so if you could get each point into its own group with the lines, you'd be set. Naively, this would mean making a copy of all the lines for every point, but that would be inefficient (and also hard to do in general).
So what is to be done? Well, the NeighbourFinder can tell you the closest line to each point. And then you can capture both the geometry and any attributes you want from that line, to later reconstitute. In effect, making a copy of the closest line to each point. As long as you have a unique ID on the points, and ensure that the copy you just made has that id, then you can use the GroupBy on the PointOnLine Overlayer to get the two segments you want.
I did a test using the City of Vancouver open data with the street network and the tree dataset. Seems to work. I'll attach what I can here -- hopefully that gets you going.
Good problem.
Screenshot below, link to workspace here
Correct answer by Dale Lutz on May 2, 2021
I saw this and thought I'd give it a quick go too. I took a slightly different approach (there are usually multiple ways to do something in FME).
I agree with Dale that you'll need multiple copies of the line. The SpatialRelator tells us how many points lie on each line, therefore how many copies we need. So a SpatialRelator followed by Cloner gets us 80% of the way there.
The last 20% is - as usual - the hardest part. We want to match each copy of the line to a single point and get its coordinates. So I extract the point coordinates (CoordinateExtractor) and ensure they are copied over in the SpatialRelator into a list.
For each copy, we extract one point feature's x/y values from the list (ListIndexer). Now we just need to split the line at that point. I thought there would be a transformer that would split a line at a given x/y value, but apparently not. So we recreate the point (VertexCreator) and then - finally - do the overlay (PointOnLineOverlayer). The key is to ensure the group-by is set.
So there's my version. In the very unlikely event that you have a problem with Dale's solution, give this a try.
Answered by Mark Ireland on May 2, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP