[英]How do I get the area of a triangle of 3 points in PostgreSQL/PostGIS?
I want to compute the area of a triangle with 3 points with QGIS or PostgreSQL/PostGIS.我想用 QGIS 或 PostgreSQL/PostGIS 计算具有 3 个点的三角形的面积。 The points are saved in a geometry column.
这些点保存在几何列中。 I have no clue how to do it...
我不知道该怎么做...
WITH j AS (
SELECT
'POLYGON((7.23 49.95,10.04 52.91,11.62 49.89,7.23 49.95))'::geometry AS poly)
SELECT ST_Area(poly) FROM j;
st_area
-------------------
6.581499999999988
(1 Zeile)
Using geometry
parameters it ..使用
geometry
参数它..
Returns the area of a polygonal geometry.
返回多边形几何的面积。 For geometry types a 2D Cartesian (planar) area is computed, with units specified by the SRID
对于几何类型,计算二维笛卡尔(平面)区域,单位由 SRID 指定
and using geography
..并使用
geography
..
For geography types by default area is determined on a spheroid with units in square meters.
对于地理类型,默认情况下,面积是在以平方米为单位的椭球体上确定的。
WITH j AS (
SELECT
'POLYGON((7.23 49.95,10.04 52.91,11.62 49.89,7.23 49.95))'::geography AS poly)
SELECT ST_Area(poly) FROM j;
st_area
-------------------
52245336562.55078
(1 Zeile)
EDIT : To create a polygon based on three points use ST_MakePolygon and ST_MakeLine (see comments):编辑:要创建基于三个点的多边形,请使用 ST_MakePolygon 和 ST_MakeLine(见评论):
WITH j (p1,p2,p3) AS (
VALUES ('POINT(7.23 49.95)','POINT(10.04 52.91)','POINT(11.62 49.89)'))
SELECT
ST_AsText(ST_MakePolygon(ST_MakeLine(ARRAY[p1, p2, p3, p1])),2)
FROM j;
st_astext
----------------------------------------------------------
POLYGON((7.23 49.95,10.04 52.91,11.62 49.89,7.23 49.95))
(1 Zeile)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.