[R-sig-Geo] Conditional operations and rasters

Thiago V. dos Santos thi_veloso at yahoo.com.br
Wed Sep 16 04:51:30 CEST 2015


Hi all,

This is probably a silly question, but I could not find an appropriate answer somewhere else.

I am trying create a raster based on conditional statements applied on an original raster.

This is some sample code:

lai <- raster(ncols=360, nrows=180)
lai[] <- 1:ncell(lai)

if (lai < 1000) {

    emiss_0  <- 0.95 + (0.01 * lai)
    emiss_nb <- 0.97 + (0.0033 * lai)


} else if (lai >= 1000) {


    emiss_0  <- 0.95
    emiss_nb <- 0.98


}

Error in if (lai < 3) { : argument is not interpretable as logical


What would be the right way to do that? 
 Greetings,
 -- Thiago V. dos Santos

PhD student
Land and Atmospheric Science
University of Minnesota



More information about the R-sig-Geo mailing list