[R] Batch open netcdf files and get variables

Marc Girondot marc_grt at yahoo.fr
Sat Apr 13 08:40:31 CEST 2013


I make an example for the use of this package here:
http://max2.ese.u-psud.fr/epc/conservation/Girondot/Publications/Blog_r/Entrees/2013/2/26_Using_package_RNetCDF_with_SST.html

Sincerely
Marc Girondot

Le 12/04/13 17:39, Enhao Du a écrit :
> Hi, I'm new to R. I have some daily soil moisture data for the year 1979 in netcdf format such as these
> sm19790101.1.nc
> sm19790102.1.nc
> .
> .
> .
> sm19791231.1.nc
>
> I need to average a variable called "sm" to monthly resolution. I've done these
>
> days = formatC(1:31, width=2, flag="0")
> ncfiles = lapply(days, function(d){
>      filename = paste("sm197901", d, ".1.nc", sep="")
>      #print(filename)
>      open.nc(filename)
> })
>
> to open the files in January. Questions is: how may I get the variable from each opened file. Rnetcdf package has the var.get.nc() that only read object of class "Netcdf" returned from open.nc(). Any help would be appreciated.
>
> Enhao
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>


-- 
__________________________________________________________
Marc Girondot, Pr

Laboratoire Ecologie, Systématique et Evolution
Equipe de Conservation des Populations et des Communautés
CNRS, AgroParisTech et Université Paris-Sud 11 , UMR 8079
Bâtiment 362
91405 Orsay Cedex, France

Tel:  33 1 (0)1.69.15.72.30   Fax: 33 1 (0)1.69.15.73.53
e-mail: marc.girondot at u-psud.fr
Web: http://www.ese.u-psud.fr/epc/conservation/Marc.html
Skype: girondot



More information about the R-help mailing list