<div dir="ltr">Hi all,<div>I have a GIS application with multiple polygons where I'd like to get the rotated bounding box of the polygons. ST_OrientedEnvelope seems to be the right function, but in my case, is returning a parallelogram instead of a rectangle.</div><div><br></div><div>I've created a simple example where the original polygon is a rectangle just to demonstrate the issue:</div><div><br></div><div><pre class="gmail-lang-sql gmail-s-code-block" style="margin-top:0px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-variant-alternates:inherit;font-stretch:inherit;font-kerning:inherit;font-feature-settings:inherit;vertical-align:baseline;box-sizing:inherit;width:auto;max-height:600px;overflow:auto;color:rgb(12,13,14)"><code class="gmail-hljs gmail-language-sql" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;vertical-align:baseline;box-sizing:inherit;background-color:transparent;white-space:inherit"><span class="gmail-hljs-keyword" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">CREATE</span> <span class="gmail-hljs-keyword" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">TABLE</span> geometries (
geometry geometry
);
<span class="gmail-hljs-keyword" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">INSERT</span> <span class="gmail-hljs-keyword" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">INTO</span> geometries(geometry) <span class="gmail-hljs-keyword" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">values</span>(ST_GeomFromText(<span class="gmail-hljs-string" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">'POLYGON((-71.25961696926942 42.470522973159675,-71.25978846747648 42.470624424600906,-71.25973918365264 42.47066975346566,-71.25956768540266 42.47056830210077,-71.25961696926942 42.470522973159675))'</span>))
<span class="gmail-hljs-keyword" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">SELECT</span> ST_AsGeoJson(st_collect(ST_OrientedEnvelope(geometry), geometry)) <span class="gmail-hljs-keyword" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">FROM</span> geometries</code></pre></div><div><img src="cid:ii_ltgtlmuv0" alt="Screenshot 2024-03-07 at 02.59.37.png" width="542" height="284"><br></div><div><br></div><div>Image link:<a href="https://www.dropbox.com/scl/fi/xoi87e06mtfsnc1qzw3wu/oriented_2.png?rlkey=37ajuo6lwdnynk9gi8hpmoolq&dl=0"> https://www.dropbox.com/scl/fi/xoi87e06mtfsnc1qzw3wu/oriented_2.png?rlkey=37ajuo6lwdnynk9gi8hpmoolq&dl=0</a></div><div><br></div><div><div>Any help is appreciated, thanks!</div></div><div><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature">Ricardo Mayerhofer</div></div></div>