Skip to content
Prev 19259 / 29559 Next

how to use levelplot() with a geographic projection

Hello,

Scott, here I propose a different way to build and fill the RasterStack
object:

## make the stack object
myrast <- raster(xmn=xmn, xmx=xmx, ymn=ymn, ymx=ymx, ncols=num.lon, nrows=num.lat)
myrast[] <- NA
raster.stack <- stack(lapply(1:4, function(i)myrast))

## use cellFromXY() to select the target cells in the raster
select.cell.numbers <- cellFromXY(raster.stack, select.coords)

## give the selected cells some values
vals <- sapply(1:4, function(i)seq(i, i+1, length=num.sel.cells))
raster.stack[select.cell.numbers] <- vals

Best,

Oscar

Waichler, Scott R writes: