Skip to main content
Question

order of polygons through which a line is passing


jelle
Contributor
Forum|alt.badge.img+16
  • Contributor

Hi All,

the blue line is going from Polygon A to B. It passes several polygons on its way (most of them are magenta).With the SpatialRelator, it is fairly easy to get a list of these polygons. However, I should be able to sort this list in the order of the polygons the line passes. Anyone done this before?

I replaced the rectangles with their Centre Point and created a network between these points. The ShortestPathFinder does not allow to force passing in each point. It just takes the shortest route in that case.

best regards,

Jelle

7 replies

Forum|alt.badge.img+2
Hi @jelle,

 

If you wanted to connect the points from every rectangle to create the blue line in this image then I believe the LineBuilder is the transformer you should use, rather than the ShortestPathFinder since without a line network to follow this will not pass through all the points. A line builder will connect the points in the order they enter so if the centre points from the polygons are not already in the correct order then you can use the Sorter transformer - providing they have a unique ID attribute that is ascending/descending.

 


takashi
Contributor
  • July 27, 2018

Hi @jelle, since the PointOnLineOverlayer will transfer the measure value at the intersection on the line to each intersected point, the following procedure could be a solution.

  1. Save the original polygon geometry as an attribute with the GeometryExtractor.
  2. Transform the polygons to their center point and send them to the Point port of the PointOnLineOverlayer.
  3. Send the line to a MeasureGenerator, and then to the Line port of the PointOnLineOverlayer.
  4. Set an appropriate value to the Point Tolerance parameter in the PointOnLIneOverlayer.
  5. Use the MeasureExtractor to extract measure from the resulting points output from the Point port of the POintOnLineOverlayer.
  6. Sort the resulting points by the measure value.
  7. Apply the GeometryReplacer to the points, in order to restore the original polygons.

pratap
Contributor
Forum|alt.badge.img+11
  • Contributor
  • July 27, 2018

Hi,

If you convert all polygons to points then "NeighborFinder" will provide the distance between point A (Base) to all points (candidate)

you can further use sorter based on distance, to identify the order of existence

Pratap


jelle
Contributor
Forum|alt.badge.img+16
  • Author
  • Contributor
  • July 27, 2018
pratap wrote:

Hi,

If you convert all polygons to points then "NeighborFinder" will provide the distance between point A (Base) to all points (candidate)

you can further use sorter based on distance, to identify the order of existence

Pratap

Hi Pratap, thanks for the suggestion, but as you can see, the line is reversing direction at some point, so I cannot just use the distance to Point (Polygon) A

 

 


jelle
Contributor
Forum|alt.badge.img+16
  • Author
  • Contributor
  • July 27, 2018
takashi wrote:

Hi @jelle, since the PointOnLineOverlayer will transfer the measure value at the intersection on the line to each intersected point, the following procedure could be a solution.

  1. Save the original polygon geometry as an attribute with the GeometryExtractor.
  2. Transform the polygons to their center point and send them to the Point port of the PointOnLineOverlayer.
  3. Send the line to a MeasureGenerator, and then to the Line port of the PointOnLineOverlayer.
  4. Set an appropriate value to the Point Tolerance parameter in the PointOnLIneOverlayer.
  5. Use the MeasureExtractor to extract measure from the resulting points output from the Point port of the POintOnLineOverlayer.
  6. Sort the resulting points by the measure value.
  7. Apply the GeometryReplacer to the points, in order to restore the original polygons.
Hi Takashi, after 12 years of FME, I still discover new transformers. I had never heard of the MeasureGenerator. I'll give it a try. Thank you for the suggestion.

 

BTW @safe: great, these tolerance parameters!

 

 


pratap
Contributor
Forum|alt.badge.img+11
  • Contributor
  • July 27, 2018
jelle wrote:
Hi Pratap, thanks for the suggestion, but as you can see, the line is reversing direction at some point, so I cannot just use the distance to Point (Polygon) A

 

 

Hi @jelle,

 

Try the same logic from both ends (start and end) and merge the results.

 

Something like 50%-50%

 

Hope this helps

 


Forum|alt.badge.img
  • July 27, 2018

Other option:

1. Send the line to MeasureGenerator

2. Save the polygon geometry

3. Use a Clipper to clip the line with polygons (keep inside features), merge clipper attribute to have the geometry

4. Use a Snipper (50%-50%) to have the middle point of the inside segments with a measure

5. Use a MeasureExtractor to get the distance

And optionnaly:

6. Restore the geometry and sort

or

6. Build a list and sort

Sample workspace attached.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings