I have two shapefiles that I am merging/combining. However, this produces more than 4,000 duplicate records. I need to have only unique records. Is this possible with OGRINFO or OGR2OGR? I've tried Select DISTINCT but it only lets me do select statement on one column/field. I can get a list of unique records but I need to create new shapefil.
There should be no problem in using many attributes in DISTINCT query at least with the SQLite SQL dialect. Test with ogrinfo:
ogrinfo -dialect sqlite -sql "select distinct geometry, attribute_1, attribute_2 from my_shapefile" my_shapefile.shp
I'm trying to do the same thing, I see in the OGR SQL documentation,
The result of a SELECT with a DISTINCT keyword is a layer with one column (named the same as the field operated on), and one feature per distinct value. Geometries are discarded.
Why they made this choice boggles my mind. But I can confirm that
ogr2ogr -dialect -sqlite -sql "select distinct LINK_ID from layer" out.shp layer.shp
Returns only the
out.dbf file, which contains the unique