从ST_MinimumBoundingRadius中选择半径 [英] select radius from ST_MinimumBoundingRadius
问题描述
我想从ST_MinimumBoungingRadius中获取半径值. 像这样的东西(来自postgresql文档)可以正常工作:
I want to get just radius value from ST_MinimumBoungingRadius. Something like this (from postgresql documentation) works just fine:
SELECT radius
FROM
ST_MinimumBoundingRadius('MULTIPOINT(1 2,3 8,5 6)')
所以我不明白,为什么不能在现有表上执行类似的查询:
So I don't understand, why doesn't work similar query on existing table:
SELECT radius
FROM
(SELECT
ST_MinimumBoundingRadius(ST_Collect(geom)) minrad
FROM a) b
此查询的结果是错误:列"radius"不存在
Result of this query is ERROR: column "radius" does not exist
有什么方法可以提取半径值?
Is there any way to extract just radius value?
推荐答案
主要字符串所有列的聚合.
The main difference is that in the first case you are calling the function in the FROM
clause while in the second it is in the select
clause. In the first case, the result is made of two column while in the later it is a string aggregation of all columns.
You can fix it by using the function in the FROM
clause again, using either a double-parenthesis or a lateral join:
SELECT radius
FROM ST_MinimumBoundingRadius((SELECT ST_Collect(geom)
FROM a)) minrad;
或
SELECT radius
FROM (SELECT ST_Collect(geom) geom FROM a) tbla,
LATERAL ST_MinimumBoundingRadius(tbla.geom) minrad;
这篇关于从ST_MinimumBoundingRadius中选择半径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!