On Thu, 4 Aug 2011, Rebecca Bennett wrote:
Hello all,
I am *very* new to R and am experimenting with the GRASS / R interface
to look at correlation of elevation and spectral values.
Reading through the literature and mailing list, I have imported my
GRASS rasters to R as a dataset looked at the summary statistics and
then attempted to run a correlation analysis using cor, along the lines
of the example here:
map <- readRAST6(c("lageado_10k_fisher_K_15x15",
"lageado_10k_fisher_K_25x25"))
summary(map)
I think that here you will see that for your current GRASS region, there
are missing values (NAs) in the first attribute.
cor(as(map, "data.frame"))
and get the output:
coombe_rev_LRM intensity_coombe x y
coombe_rev_LRM 1 NA NA NA
intensity_coombe NA 1.00000000 -0.1525509 0.09057913
x NA -0.15255095 1.0000000 0.00000000
y NA 0.09057913 0.0000000 1.00000000
so results for intensity_coombe are given, but not for coombe_rev_LRM. The
x and y are the coordinates of the raster cells are uninteresting, and are
added when you use as(..., "data.frame"). Try:
cor(as(map, "data.frame")[,1:2], use="complete.obs")
to use only the two real attributes, and to drop observations where there
are missing values. Do check that the missing values are intended, as they
may be caused by your region setting in GRASS.
Hope this helps,
Roger
so the correlation is running on the x and y values of the rasters not
the z?
How do I begin to assess correlation in the z value of two rasters?
Many thanks for reading, (and sorry if my question seems stupid or I
have missed something obvious)
Rebecca
--
Roger Bivand
Department of Economics, NHH Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: [email protected]
_______________________________________________
grass-stats mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/grass-stats