【发布时间】:2019-07-28 14:12:15
【问题描述】:
我有两张桌子,table_a 有多边形和这些多边形的质心。 table_b 有另一组点与table_a 中的几何重叠。
对于table_a 的每一行,我需要从table_b 中找到最靠近该行质心的点。
INSERT INTO nearest_node (nearest_drive_node)
SELECT osmid FROM london_drive_nodes
ORDER BY london_drive_nodes.geom <-> nearest_node.lsoa_centroid
LIMIT 1;
这会返回
SQL Error [42P01]: ERROR: invalid reference to FROM-clause entry for table "nearest_node"
Hint: There is an entry for table "nearest_node", but it cannot be referenced from
this part of the query.
我不确定如何使用来自table_a 的值作为查询的ORDER BY 部分中的点。我发现的示例是查找单个点的最近邻居作为文本字符串,而不是一列点。
【问题讨论】:
-
您确定您不是在寻找更新子句 - 您根据最接近该行的
london_drive_nodes设置nearest_drive_node吗? -
是的,你完全正确。
UPDATE不是INSERT谢谢!
标签: postgresql postgis nearest-neighbor