3

How to find a duplicate point geometries in point shapefile (around one lakh geometries) using Python OGR/GDAL

1

One approach is to use the SQLite SQL dialect. It seems to work at least with a point shapefile where I digitized a few points, some of them in the same location.

ogrinfo -dialect sqlite -sql "select geometry, count(*) from duplicate_points group by geometry" duplicate_points.shp

Layer name: SELECT
Geometry: Unknown (any)
Feature Count: 4
Extent: (271.000000, 360.000000) - (400.000000, 460.000000)
Layer SRS WKT:
(unknown)
Geometry Column = GEOMETRY
count(*): Integer (0.0)
OGRFeature(SELECT):0
  count(*) (Integer) = 1
  POINT (400 360)

OGRFeature(SELECT):1
  count(*) (Integer) = 1
  POINT (400 460)

OGRFeature(SELECT):2
  count(*) (Integer) = 4
  POINT (360 420)

OGRFeature(SELECT):3
  count(*) (Integer) = 2
  POINT (271 387)

You are interested in the cases where count(*)>1. You can use SQL queries through Python with ExecuteSQL.

Not the answer you're looking for? Browse other questions tagged or ask your own question.