Advertisement
Guest User

Untitled

a guest
Nov 24th, 2014
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. import arcpy
  2.  
  3. from arcpy import env
  4.  
  5. env.workspace = "C:/data/Habitat_Analysis.gdb"
  6.  
  7. arcpy.Statistics_analysis("FIELD_NAME", "C:/output/output.gdb/TABLE_OUTPUT", [["SUM"]])
  8.  
  9. int_fields = arcpy.ListFields("C:/data/Habitat_Analysis.gdb", , "Integer")
  10.  
  11. small_int_fields = arcpy.ListFields("C:/data/Habitat_Analysis.gdb", , "SmallInteger")
  12.  
  13. double_fields = arcpy.ListFields("C:/data/Habitat_Analysis.gdb", , "Double")
  14.  
  15. fields = int_fields + small_int_fields + double_fields
  16.  
  17. # Import system modules
  18. import arcpy
  19.  
  20. # Set environment settings
  21. env.workspace = "C:/data/Habitat_Analysis.gdb"
  22.  
  23. # Set local variables
  24. intable = "FIELD_NAME"
  25. outtable = "C:/output/output.gdb/TABLE_OUTPUT"
  26. # casefield = "Name" Not used
  27. stats = []
  28.  
  29. # Loop through all fields in the Input Table
  30. for field in arcpy.ListFields(intable):
  31. # Just find the fields that have a numeric type
  32. if field.type in ("Double", "Integer", "Single", "SmallInteger"):
  33. # Add the field name and Sum statistic type
  34. # to the list of fields to summarize
  35. stats.append([field.name, "Sum"])
  36. # Correct formatting of stats [["Field1", "Sum"], ["Field2", "Sum"], ...]
  37.  
  38. # Run the Summary Statistics tool with the stats list
  39. arcpy.Statistics_analysis(intable, outtable, stats)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement