1

I have a feature class with fields: Latitude, Longitude, Type, Magnitude, City, State, Comment.

If Latitude, Longitude , and Type are the same, I only want to keep the record with the highest Magnitude value (magnitude will vary usually).

However, sometimes there are duplicates in the data (all fields have duplicate values), so I would only want to keep one record.

I am running ArcGIS 10.3 for Desktop and Python 2.7.8.

After creating a table of max magnitude would I then join this table back to my feature class to create a new feature class?

arcpy.Statistics_analysis("C:/csv/all_reports.gdb/reportsSel", "C:/csv/all_reports.gdb/reportsSel2", [["MAG", "MAX"]], ["Type", "Longitude", "Latitude"])
  • To find the highest magnitude value I would use Summary Statistics with three case fields. If you have trouble writing a script to do that part then I think it would be best to research/ask about that step before attempting the remainder. – PolyGeo Dec 4 '15 at 20:46
  • Alternatively you could keep track of the highest values so far as your cursor proceeds using variables and a dictionary but either way you should make a code attempt to receive help with where you are stuck here. – PolyGeo Dec 4 '15 at 20:49
  • Yes I am able to write the Summary Statistics script. – Andrew Dec 4 '15 at 21:00
  • Use set and sorted function on loop arcpy.da.SearchCursor() – GeoStoneMarten Dec 5 '15 at 12:48
  • 1
    I would do Summary Statistics with all fields as case fields first to eliminate all completely duplicates, then summarize on the three case fields of latitude, longitude and type to get the max magnitude. You could use my tool at geonet.esri.com/blogs/richard_fairhurst/2015/06/07/… to create a single join field that represents the multi-field key values or adapt that code to create a dictionary based on the three case fields that could be used to select the correct set of records. – Richard Fairhurst Dec 6 '15 at 5:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.