# Mann Kendall Test

Question asked by ahsan_phy@hotmail.com on Dec 27, 2014
Latest reply on Dec 31, 2014 by xander_bakker

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 2Column 3Column 4Column 5
50259810298
1229810210100
5766922110
9845255959
5898173154

Message was edited by: Ahsan Abbas