本文所用数据为一文件夹所有tif影像,进行乘0.01的缩放因子,处理后影像放入新文件夹中
1.如果Python装好了arcgis运行环境,可以直接;python运行。
import os
import arcpy
from arcpy import env
from arcpy.sa import *
import string
arcpy.CheckOutExtension("spatial")
arcpy.gp.overwriteOutput=1
arcpy.env.workspace = "E:/04carbon/NPPyear500mMRT"
rasters = arcpy.ListRasters("*", "tif")
outPath = 'E:/04carbon/NPP0.01/'
for ras in rasters:
outrasters = outPath + str(ras)
outTimes = Times(ras, 0.01)
outTimes.save(outrasters)
print(str(ras))
print("All project is OK!")
2.可直接在arcgis中python编辑器运行。
import os
import arcpy
from arcpy import env
from arcpy.sa import *
import string
arcpy.CheckOutExtension("spatial")
arcpy.gp.overwriteOutput=1
arcpy.env.workspace = "E:/04carbon/NPPyear500mMRT"
rasters = arcpy.ListRasters("*", "tif")
outPath = 'E:/04carbon/NPP0.01/'
for ras in rasters:
outrasters = outPath + str(ras)
outTimes = Times(ras, 0.01)
outTimes.save(outrasters)
print(str(ras))
print("All project is OK!")
|