【问题标题】:Error in nearest neighbor search in PostGISPostGIS中最近邻搜索错误
【发布时间】:2018-10-10 22:38:12
【问题描述】:

我正在尝试编写一个 PostGIS 最近邻查询,其中选择了一组坐标并确定了距最近洪水多边形的距离。然后我想将距离分类为“外部”、“关闭”或“内部”:

WITH 
  point_loc (geom) AS ( 
    SELECT ST_SetSRID(ST_MakePoint(531673.0, 180848.2),27700) ),
  distances (gid, distance) AS (
    SELECT  
      fl.gid,
      ST_Distance(fl.geom, p.geom) AS distance
    FROM
      point_loc p, flooding fl
    WHERE ST_DWithin(p.geom, fl.geom, 400)
  SELECT 
    gid,
    CASE WHEN distance > 300 THEN 'OUTSIDE'
         WHEN distance > 50 AND <= 300 THEN 'CLOSE'
         ELSE 'INSIDE'
    END as flood_result
  FROM distances;

我在最后的 SELECT 调用中不断收到语法错误。谁能看到我做错了什么?

【问题讨论】:

    标签: postgresql postgis nearest-neighbor


    【解决方案1】:

    您的第二个 CTE 缺少右括号。

    这一行: WHERE ST_DWithin(p.geom, fl.geom, 400)

    应该是: WHERE ST_DWithin(p.geom, fl.geom, 400) )

    【讨论】:

      猜你喜欢
      • 2016-04-19
      • 2018-06-16
      • 1970-01-01
      • 2012-09-16
      • 1970-01-01
      • 2013-08-07
      • 1970-01-01
      • 2012-04-15
      • 1970-01-01
      相关资源
      最近更新 更多