# FME - Find and calculate part of area that is a rectangle in a polygon feature

I'm looking for a way to find the largest part of an polygon feature that is whole rectangle. Don't know if it make sense, but maybe the picture helps explain it.

So far I've been using Chopper with 5-6 vertices, Area calculator (to find the largest of the chopped parts) and a Bounding box at the end to create a rectangle. This kind of works on at least some of the features, but there got to be a better solution for this?

Well, I think there are better ways, but better is usually more complex because you're trying to cover all the bases. There are proper algorithms for this sort of thing (look up "largest rectangle in orthogonal polygon") but unfortunately there isn't any implementation inside FME.

Having said that, I think we can improve on what you have.

If you create a bounding box and cut out the main polygon, you get this:

It looks to me as if you can take the right-angled triangles and cut them out of the original, then you'll have what you need:

To get those shapes... basically, chop everything into two-point lines and extend them far enough to create the triangle shape:

Then do an intersection and build areas out of what is left:

I notice it's not quite what we might expect - because in some cases, it extends outwards too and comes out as a polygon, not a triangle - but it seems to do the trick in all of the examples I've tried. We just use it as a clip boundary against the original feature and voila:

So I hope that helps. You can find the workspace I built here on Github.

• I will say that I don't know if it will work in all cases! In particular, I wonder about when there is no rotation. But I hope it will be better than you have and at least a starting point to improve on. Commented Jun 30, 2022 at 16:54
• Thank you very very much! Will try it tomorrow, but seems easy enough to follow and a logical way of doing it. For what I'm doing it does not have to work in 100 % of the cases, so this is probably good enough Commented Jun 30, 2022 at 17:00