[GRASS-stats] R, Moran index, getis e ord.....

Roger Bivand Roger.Bivand at nhh.no
Thu Oct 7 07:25:22 EDT 2010


On Thu, 7 Oct 2010, Gabriele N. wrote:

>
> Hy everyone.
>
> I have a raster which is the result of calculating an index of remote
> sensing (with decimals).
>
> I would like to calculate the Moran's index and the index of Getis and Ord
>
> To do this I installed R (following
> http://grass.fbk.eu/statsgrass/grass6_r_install.html).
> Then I installed the packages
>
> install.packages("spdep",dependencies=TRUE)
> install.packages("maptools",dependencies=TRUE)
>
> Then from the shell:
>
> R
>
> Then load these libraries
>
> library(spgrass6)
> library(spdep)
> library(maptools)
> library(boot)
> library(Matrix)
> library(lattice)
>
> I read the raster
>
> index_water_2009<-readRAST6("index_water_2009")
>
> At this point I stopped. I saw on the mailing list and some tutorials.
>
> I can not understand the syntax to use.

Well, in rasters the number of "observations" is typically very large, 
probably artificially so, depending on the "natural" resolution of the 
phenomena of interest. Consequently, in rasters one almost always finds 
strong positive spatial autocorrelation, because the cells do not 
represent well the actual entities. If you need to do this, you can try 
in Spearfish:

library(spgrass6)
gmeta6()
execGRASS("g.region", parameters=list(res="150"))
# to coarsen the input resolution
gmeta6()
elev <- readRAST6("elevation.dem")
GT <- slot(elev, "grid")
library(spdep)
nb_rook <- dnearneigh(coordinates(elev), 0, mean(slot(GT,
   "cellsize"))*1.05)
summary(elev)
# note NAs, need to subset to handle:
mt <- moran.test(elev$elevation.dem, nb2listw(nb_rook), na.action=na.omit)
# using spatial weights row standardisation
mt

Hope this helps,

Roger

>
> It only works on vector?
>
> Someone can give me some help?
>
> Thanks
>

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no



More information about the grass-stats mailing list