Re: [GRASS-user] r.covar vs layerStats in R

Micha Silver <[email protected]> Tue, 20 Nov 2018 20:59:00 +0200
Newsgroups gmane.comp.gis.grass.devel,gmane.comp.gis.grass.user
Message-ID <[email protected]>
On 11/19/18 12:41 PM, Markus Neteler wrote:
> On Sun, Nov 18, 2018 at 10:32 PM Micha Silver <[email protected]> wrote:
>> I am preparing a correlation matrix for 7 raster layers. The results using the r.covar module are different from the R layerStats function. I suspect this is due to handling of null cells. The R function has a parameter to remove NA cells, but the GRASS module, I think, just loops over all cells, including no value.
>>
>>
>> Can anyone confirm that GRASS does not deal with null cells, and that this would cause the difference in correlation results?
> Here how r.covar treats NULL cells:
>
> https://trac.osgeo.org/grass/browser/grass/trunk/raster/r.covar/main.c#L93

Looking at lines 94 - 100, it seems that the count variable is 
incremented even when a cell value is null.

Please correct me if I'm wrong.

Since count is used in the calculation of covariance and correlation 
(lines 118-132) shouldn't it contain the number only of cells with value?


Thanks

>
> Markus

-- 
Micha Silver
Ben Gurion Univ.
Sde Boker, Remote Sensing Lab
cell: +972-523-665918

_______________________________________________
grass-dev mailing list
[email protected]
https://lists.osgeo.org/mailman/listinfo/grass-dev