Question

How to filter lines with endpoints in polygons for clipping and keeping only line segments outside polygons?

  • 5 September 2018
  • 6 replies
  • 17 views

Badge

I have polylines and polygons as separate source data. A polyline that has an end in a polygon must be clipped with a polygon, leaving only part outside the polygon. At the same time, the lines thats intersects the polygons must remain unchanged.


6 replies

Badge +2

Hi @is you can use the clipper and choose the clipper and the lines outside the polygons will be output from the "Outside" port

 

For the lines that intersect the polygons you can use the LineOnAreaOverlayer transformer to know which ones touch the polygons. You could use the SpatialFilter as well, but I prefer the first one.

Badge

I upload a picture - only red parts of polylines must be removed.

Userlevel 1
Badge +10

I upload a picture - only red parts of polylines must be removed.

Do you have the scenario where a polyline might start and end in different polygons and need to be clipped by both?

 

 

Userlevel 1
Badge +10

endpoints-in-polygons.fmwt

I would use a pattern matrix to determine which lines start/end within the polygon, then use that as a basis to group by in the clipper. If you have lines that start and end in different polygons, you then need to combine the clipped output so that only the portion of the line outside polygons is retained.

Badge
Do you have the scenario where a polyline might start and end in different polygons and need to be clipped by both?

 

 

The situation when the line starts and ends in different polygons and must be cut at both ends is possible, but is not the basic condition, because in most cases the lines start outside the polygons. Thank you for advice, @egomm .

 

Userlevel 1
Badge +10

endpoints-in-polygons.fmwt

I would use a pattern matrix to determine which lines start/end within the polygon, then use that as a basis to group by in the clipper. If you have lines that start and end in different polygons, you then need to combine the clipped output so that only the portion of the line outside polygons is retained.

I think currently this wouldn't deal correctly with the scenario where a line starts and ends in the same polygon, you would need to update the matrix to 1010F0212 1010FF212 to include this.

 

 

Reply