I have polygon shapefile with objects that have 'class' and 'area' values in attribute table. I want to select five biggest polygons in each class. I can't do it manually because of large number of shapefiles and objects in each shapefile. Is it possible with ArcGIS that I use? If not maybe some other software can do the trick... Thanks in advance for help.

edit: I can use file/personal geodatabase or SQL Server geodatabase as well if this is nessesary to make that selection. I will not be able to create python script, I would rather use some SQL selection.

  • 1
    based on TOP queries with GROUPBY, it should be possible see gis.stackexchange.com/questions/6814/select-top-query-in-arcgis – radouxju Feb 20 '14 at 7:37
  • I tried to do it in personal geodatabase but group by do not work. – Roman Feb 20 '14 at 8:17
  • I tried this in field calculator:[Shape_Area] IN (SELECT TOP 5 [Shape_Area] FROM buff1 GROUP BY [Class]) but it doesn't work – Roman Feb 20 '14 at 8:34
  • SQL statement work in definition queries from the layer properties, not in field calculator. If you want to calculate something in a field to make it "permanent", you should rather use a Python script using update cursor and arcpy, but this is another question. – radouxju Feb 20 '14 at 8:46
  • 1
    Can you edit your Question to provide more precise details of what you are asking, please? For example, it has come out in comments that you are using a Personal Geodatabase so it would now be helpful to see that as part of your Question. The thing I am keen to know is whether you are wanting to make a selection on your feature class or to select out the biggest features into a new feature class. Either is easy to do in ArcGIS using ArcPy but the simplest method will depend on knowing your precise requirements. – PolyGeo Feb 20 '14 at 10:14

You can always sort your features, first by class, then by area (descending) and, in each class, select the 5 first records.

As you say that you have many classes and many shapefiles, you obviously can do it by hand. My approach would be to use the Python API in order to perform this sorting / selecting operation.

I don't know though how familiar you are with programming / Python?

So maybe a few resources: http://resources.arcgis.com/en/communities/python/

And, more specifically (see at the end of the page for the Python examples):

Sorting: http://resources.arcgis.com/en/help/main/10.1/index.html#//001700000057000000 Selecting: http://resources.arcgis.com/en/help/main/10.1/index.html#//001700000071000000

And finally you can use the cursors to extract the 5 biggest polygons: http://resources.arcgis.com/en/help/main/10.1/index.html#//018z0000009r000000

Once you have your Python script, you can loop over all your shapefiles so that they are all processed at once.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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