首页 > 解决方案 > SELECT FROM 查询与 PostGIS 几何不工作

问题描述

我有以下查询:

SELECT "coordinate" FROM "chunk" WHERE "coordinate"=ST_SetSRID(ST_MakePoint(1, 1), 4326)

在这里,我想从一个块中选择坐标为 (1,1) 的所有行,但出现以下错误:

SQL Error [42883]: ERROR: operator does not exist: point = geometry
  Hint: No operator matches the given name and argument types. You might need to add explicit type casts.
  Position: 52

我很高兴看到任何可以帮助我解决这个问题的东西。先感谢您。

标签: postgresqlpostgis

解决方案


如果你想在 sql 的“where”部分搜索坐标,你应该使用 st_astext 函数

这是示例 sql 查询

select st_astext(coordinate),coordinate 
from (
select 
1 as id,
ST_SetSRID(ST_MakePoint(1, 1), 4326) as coordinate
) "chunk" 
where st_astext(coordinate)='POINT(1 1)'
 

推荐阅读