AnsweredAssumed Answered

Calculate Correlation and Pearson between two sets of rasters

Question asked by india123 on Aug 21, 2017
Latest reply on Jun 23, 2019 by Barjeece2
Branched from an earlier discussion
Branched to a new discussion

Branched from: Correlation between two different rasters 


Hi Xander Bakker,  Some modification I want to do in correlation script. 


I Would like to calculate the P value as a raster in addition to correlation raster. 


Using scipy library, I just ran one script to obtain the correlation and P value. Script is attached below


import numpy as np
from scipy.stats import pearsonr
x = np.array([ 58295.62187335,  45420.95483714,   3398.64920064,    977.22166306, 5515.32801851,  14184.57621022,  16027.2803392 ,  15313.01865824, 6443.2448182 ])
y = np.array([ 143547.79123381,   22996.69597427,    2591.56411049, 661.93115277,    8826.96549102,   17735.13549851, 11629.13003263,   14438.33177173,    6997.89334741])

r,p = pearsonr(x,y)

print "r", r

print "p", p



r : 0.831087956392

Pearson’s correlation coefficient

p-value : 0.00550539621039

2-tailed p-value


So instead of Numpy, can we use here Numpy and Scipy both library to get the addition p value or in the existing  script can we add this function to obtain the p Value as a raster


Thanks & regards 

Shouvik Jha