Hello Guys, I need to perform Mann Kendall test on 5 series raster data yearly basis, from 2007 to 2011.
if need to iterate pixel by pixel on raster cell values for calculating the sign. How can i do it... Below is code but i have problem with numpy...
import arcpy import numpy from arcpy import env env.workspace = r"D:\PythonProject\Data" rasterlist = arcpy.ListRasters() for raster in rasterlist: print raster n = len(rasterlist) pairs = (n * ( n - 1)) / 2 print "Pairs to be formed: ", pairs def pairsRasters(raster1, raster2): print raster1, " - ", raster2 inRas1 = arcpy.Raster(raster1) lowerLeft1 = arcpy.Point(inRas1.extent.XMin,inRas1.extent.YMin) #cellSize = inRas.meanCellWidth my_array1 = arcpy.RasterToNumPyArray(inRas1,nodata_to_value=0) inRas2 = arcpy.Raster(raster2) lowerLeft2 = arcpy.Point(inRas2.extent.XMin,inRas2.extent.YMin) #cellSize = inRas.meanCellWidth my_array2 = arcpy.RasterToNumPyArray(inRas2,nodata_to_value=0) for current in reversed(rasterlist): for previous in rasterlist: if current == previous: pass elif current > previous: pairsRasters(current, previous) else: pass
Suppose the two raster of similar extent, i need to calculate difference, if it's greater than 1 the value store in output raster would be 1, if less than 1 the value would be -1 and else zero. How can i iterate on pixel by pixel of two rasters. so i can save it into new raster. That's it..
|Column 1||Column 2||Column 3||Column 4||Column 5|
Message was edited by: Ahsan Abbas