[STATSGRASS] "Neighbourhood modifier" from r.mapcalc in R?

Agustin Lobo Agustin.Lobo at ija.csic.es
Tue Oct 16 12:51:28 EDT 2007


Have you tried shift.im() from spat.stats to create the two
shifted rasters first and then operate with them?
Or perhaps extracting the matrix from the sp object and doing
the same in matrix notation. For example, if INPUT1 is a matrix,
then
INPUT1NW <- cbind(INPUT1[,-(1:2)],NA*INPUT1[,1:2])
INPUT1NW <- rbind(INPUT1NW[-(1:2),],NA*INPUT1NW[1:2,])
and an equivalent for the SE shift (INPUT1SE)

Then
OUTPUT <- INPUT1NW*INPUT2 + INPUT1SE*INPUT2

and make an sp object with OUTPUT

Agus



Rainer M Krug escribió:
> Hi
> 
> I want to do some map calculations which involve binominal distributed 
> random numbers which I can not obtain in r.mapcalc. Therefore I import 
> the raster via readRAST6() into R and I want to do the calculations 
> there. But I am stuck...
> 
> In r.mapcalc I use somthing like
> 
> OUTPUT=INPUT1[-2,-2]*INPUT2+INPUT1[+2,+2]*INPUT2
> 
> How can I translate this into R?
> 
> rA <- readRAST6("INPUT1")
> rB <- readRAST6("INPUT2")
> but now?
> 
> rA$A gives me all cell values,
> rA[1:2,1:2]$A gives me the cell values from columns and row 1 and 2,
> 
> But I have no idea where I should put the offset in.
> 
> Rainer
> 
> _______________________________________________
> statsgrass mailing list
> statsgrass at grass.itc.it
> http://grass.itc.it/mailman/listinfo/statsgrass
> 

-- 
Dr. Agustin Lobo
Institut de Ciencies de la Terra "Jaume Almera" (CSIC)
LLuis Sole Sabaris s/n
08028 Barcelona
Spain
Tel. 34 934095410
Fax. 34 934110012
email: Agustin.Lobo at ija.csic.es
http://www.ija.csic.es/gt/obster




More information about the grass-stats mailing list