3

So i have a table (linked below) and for each unique PropertyID, i need to find the highest percentage value and extract that to a different table. I need to retain all the other attribute information as well, (which summarize or dissolve doesn't do).

I'm using ArcMap 10.3

table

2
  • Yes but summarize does save the ID so the solution is to run summarize and then join it back to the original table! Nov 9, 2016 at 20:32
  • It'll save the propertyID, but i'd lose the rest of the information. If I joined back to the original i'll just end up with the same result. The JOIN id is what i need to preserve for each propertyID Nov 9, 2016 at 20:34

2 Answers 2

1

You just need to find the highest percentage out of that table? Select the Percentage field Column, Right click the Percentage Field and hit Sort Descending, the highest value will be on the top.

I think this is what you're asking if not please be more specific.

3
  • I need the highest percentage for each unique PropertyID attribute. Nov 9, 2016 at 20:38
  • I only see one percentage field are there several each with different values.
    – NULL.Dude
    Nov 9, 2016 at 20:39
  • Maybe i'm not very clear. There's only one percentage field, but for each unique ID (in the propertyID field) i need to field the value that corresponds to the highest percentage. So PropertyID 1 would be Percentatge 69.39 2 would be 81.44 and so on. Summarize would do that but i'll lose the information from the other fields which i need to keep. Nov 9, 2016 at 20:42
0

The following script creates a stack of temporary feature layers each for all entries that share the same PropertyID (it's a simple range-loop since the values seem to be just integers). Then it copies from each temporary feature layer the one with the highest PERCENTAGE value into a new feature class or whatever is needed:

import arcpy
#this is your Parcel_Test_SpatialJoin_Tabu1:
parcel = arcpy.GetParameterAsText(0)

#returns the maximum value in the field "PERCENTAGE":
def max_percent(input): 
    cursor = arcpy.SearchCursor(input)
    percentlist = []
    for row in cursor:
        percentages = row.getValue("PERCENTAGE")
        percentlist.append(percentages)
    return max(percentlist)
#returns a temporary feature lyer resulting of expr:   
def sel_n(inputFC, expr, PropertyID):
    temp_lyr = "temp_lyr_%s" %(PropertyID)
    arcpy.MakeFeatureLayer_management(inputFC,temp_lyr, expr)
    return temp_lyr

#list to filled with the desired entries:
max_per_id = []
target = either_a_new_FC_or_a_table
#since the values of "PropertyID" seem to be all integers:
for i in range(insert_the_highest_value_of_PropertyID_here):
    expr = "PropertyID = %s" %(i)
    max_per_id.append(max_percent(sel_n(parcel,expr,i)))
    arcpy.Append_management (inputs, target, "TEST")

I didn't test this script, I just fiddled it together from what I have since i am currently working on a similar issue.

If you really need ALL values of a selection "PropertyID = X" preserved I suggest to either expand the script with arcpy.Dissolve_Management in the max_percent function or insert the other values you want to keep in separate fields programmatically. Since I do not know your requirements for your result i cant help you further.

I am sure there might be a less copious approach to this - perhaps even in ModelBuilder.

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.