Answers:
DELETE FROM foo
WHERE pkuid NOT IN (SELECT min(pkuid) --or max(pkuid)
FROM foo
GROUP BY geometry)
(摘自Denis Valeev的回答:https : //stackoverflow.com/questions/3777633/delete-duplicate-rows-dont-delete-all-duplicate)
就我而言,最有效的方法是使用图层的空间索引。通过此查询,每个重叠要素仅保留1个几何。我已经完成了将TIN转换为Linestring的测试。
delete from tin_line_sp where ogc_fid not in (
select min(s1.rowid) as id_to_keep from
idx_tin_line_sp_geometry as s1,
idx_tin_line_sp_geometry as s2
where
s1.xmin = s2.xmin and
s1.xmax = s2.xmax and
s1.ymin = s2.ymin and
s1.ymax = s2.ymax
group by s1.xmin,s1.xmax,s1.ymin,s1.ymax)
为了正确理解空间索引,这里有两个查询将空间索引转换为多边形。
create table tin_line_sp_representation as
select PolygonFromText('POLYGON(('||
xmin || ' ' || ymin || ',' ||
xmax || ' ' || ymin || ',' ||
xmax || ' ' || ymax || ',' ||
xmin || ' ' || ymax || ',' ||
xmin || ' ' || ymin || '))',25832) as geometry
from idx_tin_line_sp_geometry;
成功后,恢复几何列以可视化到您喜欢的查看器中:
select RecoverGeometryColumn( 'tin_line_sp_representation','geometry', 25832 , 'POLYGON', 2 )