1

I have a field called "Values" in ArcMap where I am just wanting to Display the 10% of the values on the map and the remainder of the values not be shown on the map.

Is there a way I can do this? I was thinking perhaps I could do a selection? Select the top 10% values in the field?

6
  • 4
    Set a definition query
    – BERA
    Jun 10, 2020 at 7:24
  • Compute new field using descending order, e.g. gis.stackexchange.com/questions/193681/… and use definition query. Or create a sorted copy of dataset.
    – FelixIP
    Jun 10, 2020 at 9:42
  • Yes can do new field descending order but I'm stuck on what the formula is for top 10% in definrion query ?
    – Vanessa
    Jun 10, 2020 at 11:21
  • I.e i can calculate the 10th percentile but not the top 10% for my range.
    – Vanessa
    Jun 11, 2020 at 5:10
  • How do you calculate top 10%?
    – BERA
    Jun 15, 2020 at 20:00

1 Answer 1

2

This is simple to do if your feature class is in a sql geodatabase - you can just set a definition query to select literally just the top 10 percent of values:

Value IN (SELECT TOP(10) PERCENT Value from gisse.DBO.MyPoints order by Value Desc)

just change Value to your field name (it appears 3 times in the code above), and change the gisse.DBO.MyPoints to reference your data source.


On the other hand, if your feature class is in a file geodatabase it's a bit more complicated, but it can be done. The way I did it is as follows:

I created a new field called TenPC and opened the Field Calculator

enter image description here

Select the Python Parser and click on "Show Codeblock" and use add this code:

x = "MyPoints"
f = "Value"
tpc = (int(arcpy.GetCount_management(x)[0])/10) + 1
y = list()
with arcpy.da.SearchCursor(x,f) as cursor:
    for row in cursor:
        y.append(row[0])
z = sorted(y,reverse=True)[:tpc]

def top_ten_pc(fieldval):
    if fieldval in z:
        return True
    else:
        return False

And this expression:

top_ten_pc(!Value!)

Changing x = "MyPoints" to reference your layer, and f = "Value" to reference the field name you're filtering on, and !Value! to also reference the field name.

enter image description here

Click OK to calculate the field. Now in your new field you should see lots of 0 and 1 values. Any feature with a 1 is in your top 10 percent of values.

enter image description here

You can now write a definition query to display only these features

TenPC = 1

Note - my Python is very rusty and I may be overthinking this, so there may be far more efficient ways to do what I've described above!

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.