在另一张表中使用空间选择来选择具有几何数据的表中的数据。

huangapple go评论52阅读模式
英文:

Spatial select on table with geometry from another table

问题

SELECT geom from hexgrids where value > 0.5 as hexselection
SELECT * from othertable where ST_Within(geom, hexselection)

英文:

Say I have two tables, one a table of hexagons called hexgrids and another table of other features called othertable.

I'd like to select features from othertable where they intersect features in hexgrids with value > 0.5

Essentially I am trying to use the result of one query as a spatial selection on another table.

SELECT geom from hexgrids where value > 0.5 as hexselection
SELECT * from other table where ST_Within( geom, hexselection)

答案1

得分: 1

你可以使用空间谓词和其他条件来加入:

SELECT * 
FROM table1
 JOIN table2 
  ON st_intersects(table1.geom, table2.geom)
WHERE table2.value > 0.5
英文:

You can join using the spatial predicate and any other conditions

SELECT * 
FROM table1
 JOIN table2 
  ON st_intersects(table1.geom, table2.geom)
WHERE table2.value > 0.5

huangapple
  • 本文由 发表于 2023年2月23日 23:42:25
  • 转载请务必保留本文链接:https://go.coder-hub.com/75547098.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定