select radius from ST_MinimumBoundingRadius

我们两清 提交于 2020-01-03 02:01:06

问题


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

Result of this query is ERROR: column "radius" does not exist

Is there any way to extract just radius value?


回答1:


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;

or

SELECT radius
FROM (SELECT ST_Collect(geom) geom FROM a) tbla,
    LATERAL ST_MinimumBoundingRadius(tbla.geom) minrad;


来源:https://stackoverflow.com/questions/48853353/select-radius-from-st-minimumboundingradius

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!