Geographic Information Systems Asked on August 26, 2021
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?
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
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.
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.
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!
Answered by Midavalo on August 26, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP