from __future__ import division import arcpy import os from arcpy import env from arcpy.sa import* # define workspace arcpy.env.workspace=r"C:\Users\mbs7038\Documents\Remove_Gauge_Outliers\test\forSlope.gdb" # enable overwriting arcpy.env.overwriteOutput=True # check spatial analyst extension arcpy.CheckOutExtension('Spatial') # define output paths slopePath=r"C:\Users\mbs7038\Documents\Remove_Gauge_Outliers\SpatialTrends\SlopeTEST.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) # Multiply raster by coefficient and add to output slope grid 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 + "/" + "floodChange_py") print 'script is complete'
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.