Reputation: 431
I would like to know that how can a value of standard deviation value can be calculated of a tiff/raster file and how can I find the range of values from it?
Background information: I have a tiff file of Gross Primary Productivity of Himalayan Region, I would like to know the value of the standard deviation of that tiff file. Lets say the mean of that tiff file is 3.23 and if the standard deviation comes 0.11 , will the range be 3.12-3.34?
I am attaching a raster example:
ras1 <- raster(matrix(c(1,1,1,2,2,2)))
Upvotes: 0
Views: 900
Reputation: 70603
To calculate any statistic from raster, you need to use []
like this:
> library(raster)
> ras1 <- raster(matrix(c(1,1,1,2,2,2)))
> xmean <- mean(ras1[])
> xsd <- sd(ras1[])
> xmean
[1] 1.5
> xsd
[1] 0.5477226
To get the range, you can probably do
> c(xmean - xsd, xmean + xsd)
[1] 0.9522774 2.0477226
Upvotes: 2