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


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:
Geometry Column = GEOMETRY
count(*): Integer (0.0)
  count(*) (Integer) = 1
  POINT (400 360)

  count(*) (Integer) = 1
  POINT (400 460)

  count(*) (Integer) = 4
  POINT (360 420)

  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.