Hi folks,

I guess I have a lot to learn to write functions but I'm stuck when using rasterEngine. It seems that it should be very easy to do but I'm missing something, apparently... I have a raster, Safranyik_zones_1961_1990, with values (integer) from 1 to 5. I would like to create five rasters for which value will be 1 when the raster Safranyik_zones_1961_1990 is equal to "i", and NA otherwise. I would like to run everything in a loop . Here's what I thought would be ok.

fun_zone <- function(Safranyik_zones,i,...) {
Safranyik_zonesb <- Safranyik_zones
Safranyik_zonesb[] <- NA
Safranyik_zonesb[Safranyik_zones == i] <- 1
return(Safranyik_zonesb)
}

for (i in 1:5){
Safranyik_zones_1961_1990b <- rasterEngine(Safranyik_zones=Safranyik_zones_1961_1990,i=i, fun=fun_zone)
assign(paste("Safranyik_zones_1961_1990b_",i, sep=""),Safranyik_zones_1961_1990b[[1]])
}

Of course, it says that Ť i ť is missing...:

>Erreur dans Safranyik_zones == i : 'i' est manquant

Any help?

Thanks in advance,

Yan


Yan Boulanger, Chercheur scientifique / Research scientist
Ressources Naturelles Canada, Canadian Forest Service
Centre de Foresterie des Laurentides
1055, rue du P.E.P.S.
C.P. 10380, succ. Sainte-Foy
Québec (Québec) Canada
G1V 4C7
Tel. : +1 418 649-6859




	[[alternative HTML version deleted]]

