python迭代计算_Python计算经过多年迭代的月平均值
早上好。在我现在需要将数据集平均为月平均值;有些数据集是双月、每周和每天。在我有我的基本代码:# Import arcpy moduleimport arcpyarcpy.env.overwriteOutput = True# Check out any necessary licensesarcpy.CheckOutExtension("spatial")arcpy.env.workspace=
早上好。在
我现在需要将数据集平均为月平均值;有些数据集是双月、每周和每天。在
我有我的基本代码:# Import arcpy module
import arcpy
arcpy.env.overwriteOutput = True
# Check out any necessary licenses
arcpy.CheckOutExtension("spatial")
arcpy.env.workspace="F:\\Converted_GIMMS3G" #change to folder with year of interest
print "Boots n Pants"
for n in range (1,10):
m=str(n)
rasters=arcpy.ListRasters("Rotategeo02_"+m+"*", "tif")#change year of tiffs you want to find
print "boots"
output = "F:\\Converted_GIMMS3G\\TEST\\Month_"+m+"_2002.tif" #change folder year and output year
for raster in rasters:
# Process: Cell Statistics
print (rasters)
arcpy.gp.CellStatistics_sa(rasters, output, "MEAN", "DATA")
for z in range (10,13):
rasters2=arcpy.ListRasters("Rotategeo02_"+str(z)+"*", "tif")#change year of tiffs you want to find
print "pants"
output = "F:\\Converted_GIMMS3G\\TEST\\Month_"+str(z)+"_2002.tif" #change folder year and output year
for item in rasters2:
print(rasters2)
arcpy.gp.CellStatistics_sa(rasters2, output, "MEAN", "DATA")
目前这种情况下:“rotatego02_”+str(z)+“*”每次只运行一年。
我想重复2000年。我自己也试过调整一下,结果却出了一大堆错误。想知道是否有人能对此提供想法或意见。在
使用2.7版本的Python编写脚本。在
我试过了:
^{pr2}$
这样做时,我得到了一个错误:File“H:/Sarah_Smith/IDS_data/ECV_SOILMOISTURE_MERGED/ECV_SOILMOISTURE_SSMV_MERGED/monthly average”_GIMMS.py“,第24行,英寸
锉刀=arcpy.ListRasters(“rotatego”+fdata+“”+m+“*”,“tif”)#更改要查找的TIFF年份
TypeError:无法连接“str”和“list”对象
更多推荐
所有评论(0)