Skip to content
Back to formatted view

Raw Message

Message-ID: <CABG0rft=WbFgAQCp9PfWrOzS-aD+-2U7k3_yQdp5Nt68SaGV=A@mail.gmail.com>
Date: 2011-09-07T18:01:22Z
From: Jonathan Greenberg
Subject: Using stack() to extract every Nth band of the input files

R-sig-geo'ers:

I'd like to make a stack from a set of 5-band images.  Using
stack(myfilenames,bands=3) doesn't appear to do it (I'm getting all
bands of all my input files).  Is it better to do something like:

my_rasters=sapply(myfilenames,function(x) { raster(x,band=3) },simplify=FALSE)
my_stack=stack(my_rasters)

... or is there an easier way to do this?

Thanks!

--j