2

I have some GPS points that I am trying to find the highest precision point for. How would I go about sorting the table by time collected and horizontal precision and then deleting the highest precision for each record?

For example:

I would want to delete the record with Horz_Prec of 17.8 and keep the 13.8 one.

enter image description here

0

2 Answers 2

2

Here's one potential approach (untested):

from collections import defaultdict

fc = 'some_fc'
fields = ('GPS_Date', 'Horiz_Prec')
lookup = defaultdict(list)

# first pass, build a dict of date -> list of precision values
with arcpy.da.SearchCursor(fc, fields) as cursor:
    for date, prec in cursor:
        lookup[date].append(prec)

# second pass, delete any row whose precision is not the max for the given date
with arcpy.da.UpdateCursor(fc, fields) as cursor:
    for date, prec in cursor:
        if prec != max(lookup[date]):
            cursor.deleteRow()

Note that it doesn't do the sort or handle the case of duplicate precision values for a given date, so you'll have to build those in if necessary

1

I figured out a way to do it using summary statistics.

  1. Created a combined time and date field called DateTime
  2. Ran summary statistics with Horz_Prec - MIN as the statistics field and DateTime as the case field
  3. Joined the new statistics table to the GPS points on the DateTime field
  4. Selected by attributes where DateTime = Stats.DateTime AND Horz_Prec <> Stats.MIN_Horz_Prec
  5. Deleted selected records

Not the prettiest solution but it seems to work.

0

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.