Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have a large polygon layer in which most of the polygons have a unique name in a text field. Of the hundreds that aren't 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, and delete the rest. Since the geometries are different I'm guessing I can't use ArcGIS' built-in duplicate finder and will need an SQL statement to do what I need but I'm far from proficient with SQL.

share|improve this question
1  
I'd start with the Summary Statistics tool (help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//…) to determine which is the Max Area for each name –  PolyGeo Mar 1 '12 at 22:53
add comment

1 Answer 1

up vote 7 down vote accepted

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.
share|improve this answer
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 Mar 1 '12 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 Mar 1 '12 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 Mar 2 '12 at 0:06
1  
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 Mar 2 '12 at 18:30
    
@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 Mar 2 '12 at 19:30
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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