Geographic Information Systems Asked on July 14, 2021
I would like to find out the orientation of a polygon and create a line of that direction.
See image below.
A true weighted orientation is non-trivial; I'd say the ST_LongestLine
within a polygon is the best approximation, and will yield consistent results over multiple iterations.
To get your initial Polygons with a column dir
in degrees of the
main orientation:
SELECT <some_column_1>,
...
<some_column_n>,
DEGREES(ST_Azimuth(ST_StartPoint(ll), ST_EndPoint(ll))) AS dir,
<geom_column>
FROM (
SELECT <some_column_1>,
...
<some_column_n>,
<geom_column>,
ST_LongestLine(<geom_column>, <geom_column>) AS ll
FROM <polygon_layer>
) q;
To get the Linestring of the main orientation, with column dir
:
SELECT *,
DEGREES(ST_Azimuth(ST_StartPoint(geom), ST_EndPoint(geom))) AS dir
FROM (
SELECT <some_column_1>,
...
<some_column_n>,
ST_LongestLine(<geom_column>, <geom_column>) AS geom
FROM <polygon_layer>
) q;
Correct answer by geozelot on July 14, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP