6

I have a large polygon layer in which most of the polygons have a unique name in a text field.

Of the hundreds that are not unique, there will be 2-4 polygons with the same name but different geometries.

I need to keep one of those polygons in each set of duplicates, the one with the largest area. I'll need to delete the rest.

Since the geometries are different I am guessing I cannot use ArcGIS' built-in duplicate finder and will need an SQL statement to do what I need.

How could I do this when I am far from proficient with SQL?

1

1 Answer 1

11

Here's how I would do it:

  1. Make sure your data are in an appropriate projected coordinate system.
  2. Add a new Double field to the attribute table called Area. Run field calculator on this new field with the expression: !shape.area! and Python as the parser.
  3. Run Summary Statistics, performing COUNT on the Name field, and MAX on the Area field we added in step 2.
  4. Join the output of Summary Statistics back to the original feature.
  5. Select by attributes with the following expression: "COUNT" > 1 AND "Area" <> Max. This will select features that are duplicates but are not the largest.
  6. Delete features to get rid of the unwanted duplicates. You could also invert the select of step 5 and export the good records as a new file.
5
  • 6
    +1 Well done. Let me add an important warning: selection in ArcGIS based on floating point fields can produce erroneous results. (Those of you who understand floating point precision will immediately guess why.) The solution is to make comparisons with a tolerance factor. In this case, use something like "COUNT" > 1 AND "Area" < 0.999999 * "Max". Otherwise you might wind up deleting all copies of some of those polygons! (This will almost certainly be true if the value of Max in the summary table is stored with different precision than Area.)
    – whuber
    Commented Mar 1, 2012 at 22:58
  • The method I came up with was somewhat similar, but involved making unique keys based on the text field and the area of the polygons in question for use with joining. I think this is probably cleaner, though.
    – Nathanus
    Commented Mar 1, 2012 at 23:48
  • 3
    @whuber that's a good point. Another possible method would be to add a string field and run Field Calculator with str(!shape.area!) before summarizing. I think this would also avoid errors in comparing floats.
    – dmahr
    Commented Mar 2, 2012 at 0:06
  • 2
    Thanks! This worked with one change and one tweak. In step 3, I needed to designate the Name field as a Case Field in the Summary Statistics operation, so the stats would be run for each unique name rather than the whole layer. Also, I used a long integer field for the area, since my main concern here was not getting a super-accurate area, just comparing one area to another. I used the Calculate Geometry feature in ArcGIS and specified square feet as the units, my areas are big enough and different enough that using square feet guaranteed no unintended duplicate areas.
    – Dan C
    Commented Mar 2, 2012 at 18:30
  • 1
    @DanC Ah yes, I did forget about the case field. A small tip: you can specify the units for field calculator geometry objects using the @ symbol, e.g. int(!shape.area@squarefeet!). See "Geometry unit conversions" on the Field Calculator Examples help page.
    – dmahr
    Commented Mar 2, 2012 at 19:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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