输入几何体具有未知(0)几何体(尽管使用了 st_transform )

Boo*_*oom 2 postgresql postgis

我有 2 张桌子:

一个包含 3 个字段的表:

id (text)
geom (geometry)

select ST_SRID(geom)
from A
where geom is not null

result: 32636
Run Code Online (Sandbox Code Playgroud)

B 表有 2 个字段:

name (text)
geom (geometry)

select ST_SRID(geom)
from B
where geom is not null

result: 0
Run Code Online (Sandbox Code Playgroud)

A.geom包含多边形

B.geom包含点

我想获得 A.id、A.geom 和 B.geom 之间的所有距离。我尝试过:

select id, st_distance(a.geom, ST_Transform(b.geom, 32636)) as dist
from A as a, B as b
where a.geom is not null
group by id, a.geom, b.geom
order by dist desc
Run Code Online (Sandbox Code Playgroud)

但我收到错误:

"input geom has unkown(0) SRID"
Run Code Online (Sandbox Code Playgroud)

如果我使用 ST_Transform 会怎样?

我该如何解决它?

Lau*_*lbe 7

该错误消息谈论的是 参数的 SRID ST_Transform,即 0。该消息意味着该函数不知道该点位于哪个坐标系中,因此无法将其转换为另一个坐标系。

文档说:

ST_Transform 经常与ST_SetSRID混淆。ST_Transform 实际上将几何图形的坐标从一个空间参考系统更改为另一个空间参考系统,而 ST_SetSRID() 只是更改几何图形的 SRID 标识符。

这里的情况似乎就是这样。

您可能应该使用SRID 32636ST_SetSRID进行解释。b.geom