我想在层中选择分隔线段的节点。我只想选择与两条线相交的节点,而不是当它们与两条以上的线相交时(例如,T形交叉点或四向交叉点等)。
这是我能给出的最好的照片(我没有发布照片的名声)。左边的-线是第一段,右边的--x--x--x线是第二段。O是我想要选择的中间节点。
--------------------------------------0--x---x--x---x---x---x--x--x--x--x--x--x--x
我不想选择超过两行接触节点的节点。
到目前为止,我已经尝试了这个查询
CREATE TABLE contacts_st_touching_faults as
SELECT ST_Intersection(a.the_geom, b.the_geom), Count(Distinct a.gid) = 2
FROM final_layer as a, final_layer as b
WHERE ST_Touches(a.the_geom, b.the_geom)
AND a.gid != b.gid
GROUP BY ST_Intersection(a.the_geom, b.the_geom)当我运行这个查询时,它给出了超过两条线相交的交叉点(T交叉点和4向交叉点)。
我也尝试过将ST_intersects代入,似乎没有ST_touches那么好用,但如果你知道如何让它们工作或任何其他方法,我将不胜感激!
谢谢你的帮助!
发布于 2013-04-24 22:09:32
这应该是可行的:
WITH contacts AS(
SELECT a.gid AS gid1,b.gid AS gid2, ST_Intersection(a.the_geom, b.the_geom) AS intersection
FROM final_layer as a, final_layer as b
WHERE ST_Touches(a.the_geom, b.the_geom)
AND a.gid<b.gid
)
SELECT *
FROM contacts c1
LEFT JOIN contacts c2
ON ((c1.gid1=c2.gid1 AND c1.gid2<>c2.gid2) OR (c1.gid1=c2.gid2 AND c1.gid1<>c1.gid2))
AND c1.intersection=c2.intersection
WHERE c2.gid1 IS NULL;如果将ST_Intersection移到最后的查询中,它的性能会更好,但我想让它更简单。
https://stackoverflow.com/questions/16180061
复制相似问题