上午。
我目前不得不将数据集平均为月平均值;一些数据集是双月刊,每周一些,每天一些。
我有基本代码:
# 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")
目前这个:“Rotategeo02 _”+ str(z)+“*”每次运行只需一年。 我想要它做的是:我想让它迭代多年,所以,2000年至2014年。我试过自己调整它只是为了得到一堆错误。想知道是否有人可以提供想法或输入。
使用2.7版本的Python进行脚本编写。
我试过这个:
# 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"
fdata = "78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 00, 01, 02 , 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13"
fdata = fdata.split(",")
for n in range (1,10):
for line in fdata:
m=str(n)
rasters=arcpy.ListRasters("Rotategeo"+fdata+"_"+m+"*", "tif")#change year of tiffs you want to find
print "boots"
output = "F:\\Converted_GIMMS3G\\Month_"+m+fdata+".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):
for line in fdata:
rasters2=arcpy.ListRasters("Rotategeo"+fdata+"_"+str(z)+"*", "tif")#change year of tiffs you want to find
print "pants"
output= "F:\\Converted_GIMMS3G\\Month_"+str(z)+fdata+".tif" #change folder year and output year
for item in rasters2:
print(rasters2)
arcpy.gp.CellStatistics_sa(rasters2, output, "MEAN", "DATA")
这样做时,我收到此错误:文件“H:/ Sarah_Smith / IDS_data / ECV_SOILMOISTURE_MERGED / ECV_SOILMOISTURE_SSMV_MERGED / monthly average_GIMMS.py”,第24行, rasters = arcpy.ListRasters(“Rotategeo”+ fdata +“_”+ m +“*”,“tif”)#更改你要找的tiff年份 TypeError:无法连接'str'和'list'对象