3

I got a Feature class with some identicial fields! Now i only need one polygon which had the same ID and this is the one with the largest size? Is there a posibility to delete the Polygons which are identical by size so that only the largest Polygons(from the ones with the same ID) are left?

For example:

ID   shape area

1    5
2    4
2    3
3    11
4    7
5    8
5    10

and i Need only the Polygons with the largest size that means the frist, second, fourth, fifth and the last!

5
  • Welcome to GIS-SE! Unfortunately, your table has no formatting which makes it hard to understand what you are after. I'm going to give you some reputation by upvoting your question and at the same time will introduce some formatting into it that may help you to edit it.
    – PolyGeo
    May 6, 2013 at 11:43
  • Polygon or polygons? If polygons, then what is the cut off size value for deleting? In addition, you also want to delete duplicate size polygons?
    – artwork21
    May 6, 2013 at 11:59
  • Polygon... if they have the same id, i only Need the one with the largest size... May 6, 2013 at 12:03
  • 1
    What should the output be when there are two or more polygons having the same largest size?
    – whuber
    May 7, 2013 at 2:17
  • it´s not possible that they have the same size! May 7, 2013 at 14:34

3 Answers 3

2

I would run the dissolve tool.

  1. Open Toolbox
  2. Data Management Tools/Generalization/Dissolve
  3. Choose your file as the input
  4. Dissolve on the relavent fields (not sure what all your data looks like so I can't give a good recommendation here)
  5. In the statistics portion select the ID field and then Statistic Type: MAX

Run the tool and you should get the results you are looking for.

2
  • What exactly does Dissolve do to collections of shapes that aren't quite the same?
    – whuber
    May 7, 2013 at 2:15
  • it all depends on which fields you perform the 'dissolve' on.
    – Craig
    May 7, 2013 at 16:42
2

This script (python) will check the records in your layer and add the IDs and their sizes to a dictionary and end with each ID associated with the largest value, then select and delete anything that is not in that dictionary.

import arcpy
dict_IDs ={}
layer = arcpy.SearchCursor("YourLayer")

for i in layer:
    record= i.getValue('Id')
    if record in dict_IDs:
        if dict_IDs[record]<i.getValue('size'):
            dict_IDs[record]=i.getValue('size')
    else:
        dict_IDs[record]=i.getValue('size')

for record_id in dict_IDs:
    qry="Id= "+str(record_id)+" and size <> "+str(dict_IDs[record_id])
    arcpy.SelectLayerByAttribute_management("YourLayer","ADD_TO_SELECTION",qry)

arcpy.DeleteRows_management("YourLayer")
2
  • 1
    One subtle, and probably unexpected and unintended, behavior of this solution is that records with duplicate values of [Id] that are tied for the largest value of [shape area] will all be retained, so the output can still have duplicates.
    – whuber
    May 7, 2013 at 2:15
  • A solution to the problem @whuber has mentioned would be to run this script first and then run a second, simpler script that simply deletes all [Id] field duplicates. This second script would produce your final output.
    – Conor
    Nov 11, 2013 at 17:06
0

Unless I have misunderstood what you are asking, a single tool can do this, it is the Delete Identical tool. The only caveat is that it requires Advance (ArcInfo) license level.

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.