# Making an ellipse based on an ellipse-like polygon in QGIS

I'm using QGIS. I have a layer that contains ellipse-like polygons as in the image. I need to convert them to ellipses. They come from a different data sources. These are all actually regular shapes that originate from ellipses. Therefore, I think, somehow, an ellipse containing all vertices can be formed. But an approximate ellipse also works for me. I use Smooth tool using different parameter values. But it doesn't give expected ellipses (brown polygons in the next image). And they are not bounding ellipses. If all ellipses had the same size, the Smooth + Buffer tools combination or "outer (positive) then inner(negative) buffer" could be work. How can I convert them to proper (bounding) ellipses?

• Do you want an ellipse that goes through the vertex points of the polygons? In which case five vertex locations are sufficient to create a unique ellipse through them using planar geometry. See "Conic through 5 points" here: geogebra.org/classic May 2 at 17:48
• @Spacedman An approximate result works for me. All shapes are actually well shaped like a simplified ellipse which has 16-20-24... vertices. Therefore, somehow an ellipse containing every vertices can be formed. May 2 at 18:01
• @CyrilMikhalchenko This is a good approach. Thank you. However, I think of using Python as a future work. May 3 at 11:39
• @CyrilMikhalchenko there may be a function for a regular shape, I hope. I will check later. May 3 at 11:43
• +10, that's a good question and a new geo-tool could come out of it... May 5 at 18:35

1. Create `Oriented minimum bounding box`

2. From these, create elipses with values from the attribute table calculated in the first step: `make_ellipse(centroid (\$geometry), "height"/2, "width"/2 ,"angle")`

Screenshot: here with `segements=200` for a smooth ellipse (blue): You could try something like:

``````make_ellipse(centroid(\$geometry),bounds_width(\$geometry)/2,bounds_height(\$geometry)/2,main_angle(\$geometry),45)
``````

45 is the number of segments, change that to whatever smoothness you wish.

Or alternatively if the `main_angle()` does not match your needs, try something like:

``````make_ellipse(centroid(\$geometry),bounds_width(\$geometry)/2,bounds_height(\$geometry)/2,main_angle(make_line(centroid(\$geometry),closest_point(centroid(\$geometry),\$geometry)))-90,45)
``````