# Point Feature Percentiles: National Rank vs Local Rank in ArcGIS

I have an idea in my head, but need assistance in how to process my data to get the answers I need.

Restrictions: Where I work we use Esri products, and third-party packages and add-ins are prohibited, so packages such as R or QGIS are not available to me. Python or ModelBuilder are available.

Problem Statement: I have a nation-wide point data set with values (approximately 60k points). The higher the value, the more "important" the site. Nationally, a site may rank low, but I am interested in how that site ranks to those nearby it. The goal is to find the local "big dog" sites.

Minimum value is 0. In practice, the maximum value is 119, but the theoretical maximum value is unlimited.

I do not want to divide the analysis by state, county, or any other political boundary. That would provide a scenario whereby a site would ignore a nearby site just over a border. The question I am trying to answer is "How do I compare to all of the sites within X miles of me?"

I would like to have three columns in the table:

1) Value:
This is the existing value

2) National Percentile:
A normalized value between 0-100 that indicates rank nationwide
ex: 99; 50; 23

3) Local Percentile:
A normalized value between 0-100 that indicates rank locally
Ideally, I would like an assessment done for each point that selects all points within X miles and determines the percentile of that point for the set of points within X miles of that one. Let's assume X = 100 miles
ex: 99; 50; 23

1) is just the value itself and 2) is just the stats/histogram break down into 100 bins. You can do this any number of ways (ex. use the classifier in the symbology tab>Quantities>Graduated colors).

So it sounds like #3 is really the heart of your question. A word of warning, this method will create a lot of files, so it would be helpful to build in a delete for the intermediate files. Conceptually you will be creating a search cursor, isolating the point, making a featureclass of everything but the point, and then spatial joining the two. I did something similar with tern nests that I took bits of code from below, since I don't have anything specific to your project to go on:

``````import arcpy

# Create workspace
out_folder_path = r"C:\LTPP_prep\results"
workspace = out_folder_path + r"\working\Black_Box.gdb"
env.workspace = workspace

# Specify point fc, sheet is a string that came from omitted steps where I converted excel spreadsheets
NestIDs = workspace +"/"+ sheet + "_Nest_IDs"

# Create layer files
arcpy.MakeFeatureLayer_management(NestIDs, nestLayer)
arcpy.SaveToLayerFile_management(nestLayer, nestLayerLYR)

# Create and empty list to merge all the joins back into a single fc
mergeList = []

# Create search cursor
cursor1 = arcpy.SearchCursor(NestIDs)
for row in cursor1:
focalNest = row.Nest
focalNestID = row.NUID

# Export the focal nest to its own feature class
focalNestFC = r"\FocalNest"+sheet+str(focalNestID)
arcpy.SelectLayerByAttribute_management(nestLayer, "NEW_SELECTION",'"Nest" = '+"'"+str(focalNest)+"'")
arcpy.CopyFeatures_management(nestLayer, focalNestFC)

# Switch selection and export all nests but the focal nest
statsNestFC = "StatsNest"+sheet+str(focalNestID)
arcpy.SelectLayerByAttribute_management(nestLayer, "SWITCH_SELECTION")
arcpy.CopyFeatures_management(nestLayer, statsNestFC)

# Perform the spatial join, I omitted the field mappings portion as you will have to specify that yourself for your data depending on what stats you want
focalNestJoin = "FocalNest"+sheet+str(focalNestID)+ "join"
arcpy.SpatialJoin_analysis(focalNestFC, statsNestFC, focalNestJoin, "#", "#", fieldmappings, "WITHIN_A_DISTANCE", "100")

mergeList.append(focalNestJoin)

# Merge joins
arcpy.Merge_management(mergeList, "finalresult")
``````
• In the final spatial join your map units are unlikely in miles, as I indicated by the 100, so you'd likely have to do a conversion to feet or meters. – RGfromRWBJV Jun 27 at 15:52