问题
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