从ST_MinimumBoundingRadius中选择半径 [英] select radius from ST_MinimumBoundingRadius

查看:94
本文介绍了从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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆