Solved

How to clip an area by a line


Badge

Hi All,

I have a polygon that I want to split by a line feature. I'm rather surprised to find out that there don't seem to be any tools that do this, or at least, none I've found yet. There are a lot of questions about this, but no consistent answers, or simple way of doing it.

Clipper - The Clipper feature needs to be an Area. Mine is a line.

LineOnAreaOverlayer - splits the line, not the area. :-/

Intersector - output is lines that don't reflect input areas nicely.

So, have I missed something? Is there a transformer for doing this? This is GIS 101 level geometry handling, so I'd be surprised if there isn't, but where is it hiding?

Thanks

icon

Best answer by andreaatsafe 15 February 2023, 19:29

View original

11 replies

Userlevel 2
Badge +16

A way of doing this (and it is not as straight forward as 1 transformer):

Create lines from the area (GeometryCoercer) and do a InterSector (use the line output).

Then use an AreaBuilder to recreate the areas from the intersected lines.

Badge +8

Let's say if there was no transformer I would clip the lines with the polygons, use the chopper on the polygons with a number 2 for the maximum number of vertices. merge all the lines (the clipped ones and the results from the polygons) then rebuild the polygons with the new lines with the area builder.

If I want to get back the attributes from the original polygons, I would use the AreaOnAreaOverlayer transformer.

 

 

Perhaps there are other more easier methods to do so.
Badge +22

I agree that it's an odd gap.

 

I have a custom transformer that does this, that unfortunately I can't share but essentially uses a TopopolyBuilder followed by an AreaBuilder on the lines then some spatial filtering to transfer the attributes from the original polygon (and drop any constructed polygons that do not have an equivalent orginal)
Badge
Thanks for the responses. I've submitted an idea here: https://knowledge.safe.com/idea/46814/transformer-to-split-a-polygon-by-line.html

 

Userlevel 1
Badge +21

Similar to @erik_jan . I coerce the area geometries to lines, LineOnLineOverlayer followed by an Area Builder. As long as the lines don't share any attribute names with the lines then using the accumulation mode 'merge incoming attributes' will preserve all the original attributes associated with the areas

Badge +22

Similar to @erik_jan . I coerce the area geometries to lines, LineOnLineOverlayer followed by an Area Builder. As long as the lines don't share any attribute names with the lines then using the accumulation mode 'merge incoming attributes' will preserve all the original attributes associated with the areas

An easy fix for that is to remove all attributes from the lines just prior to the LineOnLineOverlayer.

Another way is to create a topology with Topology builder (Input = your lines + polygons), then from the output "Edges" you recreate polygon and you keep only the polygons that are within the original ones...

Userlevel 4
Badge +25
Thanks for the responses. I've submitted an idea here: https://knowledge.safe.com/idea/46814/transformer-to-split-a-polygon-by-line.html

 

Thanks. Yes that's odd that we don't already have that functionality. There is a request already to split the areas in a LineOnAreaOverlayer, filed as PR#62406 with our developers. I'm going to post a comment there that links to this thread and the idea. The PR priority is already very high, so I can't really increase it any more. But it does mean we might get to this sooner rather than later.

 

Badge +10

@Jonathan Like already stated on the Ideas page: I created a custom transformer with the name PolygonCutter. You can find it on the FME HUB. Just click here

Badge +10

I'm please to let you know that the LineOnAreaOverlayer has a new mode for splitting areas with lines. This is available in FME 2023.0 betas: www.safe.com/beta

Badge +22

I'm please to let you know that the LineOnAreaOverlayer has a new mode for splitting areas with lines. This is available in FME 2023.0 betas: www.safe.com/beta

That is good news. I just checked and our custom transformer to do this was written in 2012, so I'm expecting some improved performance with the LOAO mode.

Reply