Branched from: https://community.esri.com/thread/199323-re-trend-analysis-through-time-series-of-raster-data
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
<SPAN class="keyword token">import</SPAN> numpy <SPAN class="keyword token">as</SPAN> np
<SPAN class="keyword token">from</SPAN> scipy<SPAN class="punctuation token">.</SPAN>stats <SPAN class="keyword token">import</SPAN> pearsonr
x <SPAN class="operator token">=</SPAN> np<SPAN class="punctuation token">.</SPAN>array<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">[</SPAN> <SPAN class="number token">58295.62187335</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">45420.95483714</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">3398.64920064</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">977.22166306</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">5515.32801851</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">14184.57621022</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">16027.2803392</SPAN> <SPAN class="punctuation token">,</SPAN> <SPAN class="number token">15313.01865824</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">6443.2448182</SPAN> <SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN>
y <SPAN class="operator token">=</SPAN> np<SPAN class="punctuation token">.</SPAN>array<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">[</SPAN> <SPAN class="number token">143547.79123381</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">22996.69597427</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">2591.56411049</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">661.93115277</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">8826.96549102</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">17735.13549851</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">11629.13003263</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">14438.33177173</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">6997.89334741</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN>
r<SPAN class="punctuation token">,</SPAN>p <SPAN class="operator token">=</SPAN> pearsonr<SPAN class="punctuation token">(</SPAN>x<SPAN class="punctuation token">,</SPAN>y<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN> <SPAN class="string token">"r"</SPAN><SPAN class="punctuation token">,</SPAN> r
<SPAN class="keyword token">print</SPAN> <SPAN class="string token">"p"</SPAN><SPAN class="punctuation token">,</SPAN> p
<SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
Output
| Returns: | r : 0.831087956392 Pearson’s correlation coefficient
p-value : 0.00550539621039 |
|---|
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