I did a python script to do a query from the UF field from my attribute table. The code is very simple and works well. The output show me a map with the selected values.
Now I neeed to sum the values from another field (lets call this field "NEW") only from the selected features from UF field.
import arcpy
mxd = arcpy.mapping.MapDocument("CURRENT")
for lyr in arcpy.mapping.ListLayers(mxd):
if lyr.name == "Brasil_Municipios":
lyr.definitionQuery = "UF = 'GO'"
arcpy.RefreshActiveView()
arcpy.RefreshTOC()
I can get the SUM with Summary Tool, but how to print in the screen the result?
import arcpy
mxd = arcpy.mapping.MapDocument("CURRENT")
fc = 'G:\AgroBD.gdb\Brasil_Municipios'
for lyr in arcpy.mapping.ListLayers(mxd):
if lyr.name == "Brasil_Municipios":
lyr.definitionQuery = "UF = 'GO'"
arcpy.Statistics_analysis("Brasil_Municipios",
"G:\AgroBD.gdb\Brasil_Municipios2", [["media", "SUM"]], "")
arcpy.RefreshActiveView()
arcpy.RefreshTOC()