11

I have a layer that contains ellipse-shaped geometries. The layer has projected CRS and there are also rotated ellipses in the layer. I couldn't find a tool or plugin related to semi-major and semi-minor of an ellipse.

Is there a way to calculate semi-major and semi-minor axis length?

enter image description here

I have added the blue points and green lines just for representation.

3
  • Are their nodes arranged in a way that they would touch those lines exactly? Then you could (ab)use distances to the centroid I guess. Otherwise I'd try oriented rectangles and use the lengths of the sides. Commented Apr 23, 2021 at 20:38
  • 1
    If the vertices are in a projected spatial reference, then once you have the center, semi-major and semi-minor are min and max distance to vertices, and orientation is the angle to the semi-major vertex. If it's a geographic SR, you can still calculate, but you need to work through forward and inverse geodesic functions.
    – Vince
    Commented Apr 23, 2021 at 20:42
  • @bugmenot123 Some lines (maybe many of them) don't touch any vertices. I mean many touches directly a boundary segment. Commented Apr 23, 2021 at 20:59

3 Answers 3

12

Processing Toolbox -> Vector geometry -> Oriented minimum bounding box tool may be another solution. This tool already generates the width and height of the bounding boxes.

enter image description here

enter image description here

Half of both will give you the semi-minor/major lengths with a negligible error. Then use Field Calculator to calculate them using "width"/2 and "height"/2.

0
7

Use Menu Processing / Toolbox / Minimum bounding geometry / Minimum Oriented Rectangle. Than the values you look for correspond to half of the sited of the rectangle.

Edit: as described in @Kübras solution, the Minimum Oriented Rectangle already contains an attribute for width and height - thus the following step, desribed in the original answer, is not necessary.

To calculate the sites, convert the polygon to lines and explode the lines - this last tool will automatically create an attribute for width and height.

Screenshot: I created the ellipse with this expression: make_ellipse( make_point (0,0), 22, 55, 72) - thus 22 and 55 for semi-minor/semi-major axis, 72 for azimuth. This corresponds almost to half of the values for the width/height attributes - the ellipse is not really round an contains just the default number of 36 segments, hence the rounding error: enter image description here

4

Calculate your ellipse center point if you do not already know it. create a Euclidean distance raster from that point. Then, use zonal statistics to get the minimum and maximum values using the ellipse and the Zonal Statistics tool.

1
  • 4
    Isn't there a way to do it without messing with Raster? Commented Apr 23, 2021 at 20:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.