pixel-wsie correlation between raster stack and numeric vector?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

pixel-wsie correlation between raster stack and numeric vector?

Mike Loranty
Hi All,

Is there a way (e.g. existing function) to calculate correlation
coefficients between a raster stack and a numeric vector? For example,
between gridded vegetation indices and a vector of atmospheric oscillation
indices (e.g. ENSO, NAO, etc...).

Thanks,
Michael Loranty
Assistant Professor
Department of Geography
Colgate University
315.228.6057
[hidden email]
http://mikeloranty.wordpress.com/

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Re: pixel-wsie correlation between raster stack and numeric vector?

Thomas Adams-2
Michael,

I would combine the use of GRASS GIS and R (making use of spgrass7); first,
using the vector point locations:

(0) import raster and vector data into GRASS GIS
(1) use GRASS v.sample (http://grass.osgeo.org/grass70/manuals/v.sample.html)
to sample the raster data at the vector point locations
(2) launch R within the GRASS GIS session, load spgrass7 library
(3) within R (using spgrass7) read the both vector datasets (the original
vector data and new data from using v.sample) from GRASS
(4) do R statistical analyses

All this can be easily scripted for batch processing.

Tom

On Mon, Feb 23, 2015 at 4:14 PM, Mike Loranty <[hidden email]> wrote:

> Hi All,
>
> Is there a way (e.g. existing function) to calculate correlation
> coefficients between a raster stack and a numeric vector? For example,
> between gridded vegetation indices and a vector of atmospheric oscillation
> indices (e.g. ENSO, NAO, etc...).
>
> Thanks,
> Michael Loranty
> Assistant Professor
> Department of Geography
> Colgate University
> 315.228.6057
> [hidden email]
> http://mikeloranty.wordpress.com/
>
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Re: pixel-wsie correlation between raster stack and numeric vector?

Robert Hijmans
In reply to this post by Mike Loranty
MIke, I think you can use the 'calc' function for that:

library(raster)
# example data
set.seed(0)
s <- stack(system.file("external/rlogo.grd", package="raster"))
s <- stack(s, s[[1]]*runif(ncell(s)), s[[2]]*runif(ncell(s))/10,
s[[3]]*runif(ncell(s))+10)

# example vector
v <- 1:6

x <- calc(s, fun=function(x) cor(x, v))
plot(x)

Robert


On Mon, Feb 23, 2015 at 1:14 PM, Mike Loranty <[hidden email]> wrote:

> Hi All,
>
> Is there a way (e.g. existing function) to calculate correlation
> coefficients between a raster stack and a numeric vector? For example,
> between gridded vegetation indices and a vector of atmospheric oscillation
> indices (e.g. ENSO, NAO, etc...).
>
> Thanks,
> Michael Loranty
> Assistant Professor
> Department of Geography
> Colgate University
> 315.228.6057
> [hidden email]
> http://mikeloranty.wordpress.com/
>
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo