【发布时间】:2020-07-15 07:55:39
【问题描述】:
我们在数据库中有一个包含地理位置的单个树木的数据库,我们似乎有一个几何点,该点由经纬度组合而成,命名为estimated_geometric_location。我们每月都会定期更新这些树。我想获得具有两个属性的树列表。我正在寻找确定特定树的最可能更新,即。当来自一个跟踪事件的一组新树出现时,我们需要运行一个例程,建议日期条目 x.2 是数据点 x.1 的更新。理想情况下,此例程然后更新新数据点(子),添加较旧的母数据点,然后希望代表同一棵树。
到目前为止,我有类似的东西,但数据库没有响应(或者我等待的时间不够长......到目前为止等了大约 10 分钟)
SELECT
i.id
,ST_Distance(i.estimated_geometric_location, i.b_estimated_geometric_location) AS dist
FROM(
SELECT
a.id
,b.id AS b_id
,a.estimated_geometric_location
,b.estimated_geometric_location AS b_estimated_geometric_location
,rank() OVER (PARTITION BY a.id ORDER BY ST_Distance(a.estimated_geometric_location, b.estimated_geometric_location)) AS pos
FROM trees a, trees b
WHERE a.id <> b.id) i
WHERE pos = 1
如果能就此获得一些想法会很棒。我从某处的帖子中得到了这个并对其进行了改编,但到目前为止还没有运气。
【问题讨论】:
标签: postgresql postgis