Answers:
要获得点并链接到原始几何体,请使用
SELECT (ST_DumpPoints(the_geom)).path as path, id, (ST_DumpPoints(the_geom)).geom FROM linestrings)
并从http://wiki.postgresql.org/wiki/Deleting_duplicates中删除重复项
请记住,您需要有一个唯一的ID才能进行重复删除,如果没有,则需要创建一个ID
SELECT (ST_DumpPoints(the_geom)).path as path, id, (ST_DumpPoints(the_geom)).geom FROM linestrings
就第一个问题而言,就有一个PostGIS函数ST_DumpPoints。
docs页面中的第一个示例正是您所需要的。这是一个返回集合的函数,因此它不仅可以转储点,还可以转储一些信息(将其与原始几何图形相关联)。由于您只在乎要点,因此可以尝试执行以下操作:
SELECT (dp).geom FROM (
SELECT ST_DumpPoints(geom) AS dp
FROM linestrings
)
广告1。
CREATE TABLE points AS
SELECT ST_PointFromWKB(ST_AsEWKB(linestring_geom)) AS point_geom FROM linestring_table;
广告2. 选择重复点PostGIS
CREATE TEMPORARY TABLE temp AS
SELECT *
FROM points AS a, points AS b
WHERE ST_Equals(a.geom, b.geom) AND a.id <> b.id;
DROP FROM points USING temp WHERE points.id=temp.id;
OGC WKB expected, EWKB provided - use GeometryFromEWKB() for this
。您可以完全跳过ST_AsEWKB()
,但是仍然没有任何意义,请参阅ST_PointFromWKB中
要仅转储唯一点,可以使用带有SELECT DISTINCT ON
表达式的几个子查询:
SELECT geom, gid, path
FROM (
SELECT DISTINCT ON (geom) geom, path, gid
FROM (
SELECT (ST_DumpPoints(the_geom)).geom, (ST_DumpPoints(the_geom)).path, gid
FROM my_linestrings_table
) f
ORDER BY geom, path, gid
) f
ORDER BY gid, path;