我正在尝试编写一个PostGIS最近邻居查询,其中选择了一组坐标,并确定了与最接近的泛滥多边形的距离。然后,我想将距离分类为“外部”,“关闭”和“关闭”。或者' INSIDE':
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调用中遇到语法错误。谁能看到我做错了什么?
答案 0 :(得分:1)
您在第二次CTE上错过了一个右括号。
这一行:
WHERE ST_DWithin(p.geom, fl.geom, 400)
应该是:
WHERE ST_DWithin(p.geom, fl.geom, 400) )