我找到了一种计算栅格时间序列上的斜率的方法,该方法显示为here。结果是完美的,因为它真的很快,并且结果是我想要的倾斜栅格。这是代码:
from __future__ import division
import arcpy
import os
from arcpy import env
from arcpy.sa import*
# define workspace
arcpy.env.workspace=r"C:/Users/..."
# enable overwriting
arcpy.env.overwriteOutput=True
# check spatial analyst extension
arcpy.CheckOutExtension('Spatial')
# define output paths
slopePath=r"C:/Users/....gdb"
# list all rasters in the workspace
rasters=arcpy.ListRasters('*')
# sort rasters numerically
rasters.sort()
# get the number of rasters
n=len(rasters)
print(n)
# setup index
i=1
# define division
seed=(n*n*n)-n
print('the global seed is {0}'.format(seed))
for raster in rasters:
print(i)
coef=(12*(i)-((6*n)+(6*1)))/seed
print('Raster {0} is {1}:'.format(i,raster))
print('the coef for raster {0} is {1}'.format(i,coef))
# Multiple raster by coefficient
if i==1:
outSlope=(Raster(raster)*coef)
i+=1 # same as saying i=i+1
else:
print('adding {0} to outSlope'.format(raster))
outSlope=outSlope+(Raster(raster)*coef)
i+=1
if i==6:
break
# Save final slope grid
print('saving final slope grid')
outSlope.save(slopePath + "/" + "EVIChange_py")
print('script is complete')
我的问题是,是否有一种方法可以像第一个in this thread那样构建一个简单的图,以便以不同的方式表示结果。我不熟悉arcpy
,这就是为什么我找不到解决办法的原因。