[R-sig-Geo] Adding raster files from a folder
jon.skoien at jrc.ec.europa.eu
jon.skoien at jrc.ec.europa.eu
Tue Dec 13 14:24:32 CET 2011
Hi Sajid,
You should be able to do something like this:
setwd( name of folder)
fls = list.files() # you can add a pattern if you only want files of a
certain type
dst = stack(fls[1])
for (ifile in 2:length(fls)) dst = addLayer(dst, raster(fls[ifile]))
And I am sure someone can do this even shorter...
Cheers,
Jon
On 13-Dec-11 12:03, sajid pareeth wrote:
> Hi
>
> I have number of raster files(more than 100) in a folder for which I want
> to do some zonal stats.
>
> My question is how to add these raster files into R environment. Is there
> any way to do that together? Like batch files, where we give the folder and
> all the files from that folder will be processed automatically.
>
> I want to make a stack of these rasters and do the processing.
>
> So instead of typing each file names in Stack (r1,r2,r3....) , I want to
> call them automatically from a folder.
>
> Any idea in this direction???
>
> Thanks and Regards
>
>
--
Jon Olav Skøien
Joint Research Centre - European Commission
Institute for Environment and Sustainability (IES)
Global Environment Monitoring Unit
Via Fermi 2749, TP 440, I-21027 Ispra (VA), ITALY
jon.skoien at jrc.ec.europa.eu
Tel: +39 0332 789206
Disclaimer: Views expressed in this email are those of the individual and do not necessarily represent official views of the European Commission.
More information about the R-sig-Geo
mailing list