[R-sig-Geo] apply a formula by matrix
Alfredo Alessandrini
alfreale74 at gmail.com
Thu Jul 7 12:32:16 CEST 2011
Hi,
I've to apply a formula to a raster in relation to an index table
created from raster stack.
I'm trying to explain the problem:
I've three raster with same resolution, that I join in a raster
RasterStack, and from it I can obtain a table like this:
> data <- stack(dem,aer550,aer550_type)
> unique(as.matrix(data))
layer_1 layer_2 layer_3
[1,] 1 0.2460000000 2
[2,] 1 0.1845000000 2
[3,] 1 0.0000000001 2
[4,] 0 0.0000000001 2
[5,] 1 0.1476000000 2
[6,] 1 0.0000000001 0
[7,] 0 0.0000000001 0
.........
........
>From this table I develop a linear model that after I've to apply to
another raster that isn't in the raster stack and it has a higher
resolution.
I've to compute the function for the raster with higher resolution,
according to the coefficients of the rows, and only for specific
pixels.(layer_1 = 1 AND layer_2 = 0.246 AND layer_3 = 2) --> function
( -0.2710751 0.7981552 )
layer_1 layer_2 layer_3 coeff_model_1 coeff_model_2
1 1 0.2460000000 2 -0.2710751 0.7981552
2 1 0.1845000000 2 -1.1499351 -0.6216590
3 1 0.0000000001 2 -0.6643215 0.1993647
4 0 0.0000000001 2 -1.0418143 1.5379033
5 1 0.1476000000 2 2.3148048 0.8951158
6 1 0.0000000001 0 -0.2710751 0.7981552
7 0 0.0000000001 0 -1.1499351 -0.6216590
.......
.......
Thanks in advance,
Alfredo
More information about the R-sig-Geo
mailing list