所以,我想基于公共标识符(在下表中,字段'IWUP')对表中的值求和的方法。我的表看起来像这样:
+--------------------+--------------------+--------------------+--------------------+
|IWUP |Site |Date |PPG
+--------------------+--------------------+--------------------+--------------------+
|1985001 |1234 |01/01/2012 | .03 |
|1985001 |1235 |01/01/2012 | .23 |
|1985001 |1236 |01/01/2012 | .35 |
|1985001 |1234 |01/02/2012 | .03 |
|1985001 |1235 |01/02/2012 | .03 |
|1985001 |1236 |01/02/2012 | .03 |
|1985001 |1234 |01/03/2012 | .03 |
|1985001 |1235 |01/03/2012 | .03 |
|1985001 |1236 |01/03/2012 | .03 |
这是由一些arcpy代码生成的临时表:
arcpy.MakeTableView_management(PUMPAGE_PPG_DATA, PPG_DATA_View, "IWUP =1985001", "", "IWUP; SITE; DATE; PPG")
我想总结每个网站和月份的PPG数据并生成如下内容:
+--------------------+--------------------+----------------------------+
|IWUP |Date |PPG
+--------------------+--------------------+----------------------------+
|1985001 |01/02/2012 |SUM(Sites 1234, 1235, 1236) |
|1985001 |01/03/2012 |SUM(Sites 1234, 1235, 1236) |
|1985001 |01/04/2012 |SUM(Sites 1234, 1235, 1236) |
然后我可以绘制
x = []
y = []
fig = plt.figure()
table = QUERY
fields = ["Date", "PPG"]
with arcpy.da.SearchCursor(table, fields) as rows:
for row in rows:
x.append(row[0])
y.append(row[1])
plt.plot(x,y, marker='o', linestyle='-', color='b')
plt.show()
答案 0 :(得分:1)
您应该将Spatial Statistics与PPG一起用作statistics_field,将IWUP和日期用作case_fields:arcpy.Statistics_analysis(in_table, out_table, [["PPG", "SUM"]], ["IWUP", "Date"])