[R-sig-Geo] Selecting variable within nc file in raster() or brick()
Michael Sumner
mdsumner at gmail.com
Fri Jan 9 12:48:14 CET 2015
Use the varname argument to choose a specific variable. Try
brick(file.path(ncdir,nom5))
it will tell you what to do. The level argument provides a similar facility
for slicing from a 4d var, btw.
Cheers, Mike
On Fri, 9 Jan 2015 22:37 Agustin Lobo <alobolistas at gmail.com> wrote:
> Hi!
>
> For nc (v3) files having only 1 field variable along time such as
> open.ncdf(file.path(ncdir,nom1))
> [1] "file /media/alobo/FREECOM
> HDD/BIGFILES/IMASCOARSESTOCK/SMOS/_DELSMH001DIBEA.nc has 4
> dimensions:"
> [1] "time Size: 257"
> [1] "lat Size: 1100"
> [1] "lon Size: 1600"
> [1] "time_strlen Size: 20"
> [1] "------------------------"
> [1] "file /media/alobo/FREECOM
> HDD/BIGFILES/IMASCOARSESTOCK/SMOS/_DELSMH001DIBEA.nc has 1 variables:"
> [1] "float HighRes_Soil_Moisture[lon,lat,time] Longname:1 km Soil
> Moisture Missval:-999"
>
> I can simply use
> nc1 <- brick(file.path(ncdir,nom1))
>
> But, what in the case of having several variables in the nc file, i.e.:
> open.ncdf(file.path(ncdir,nom5))
> [1] "file /media/alobo/FREECOM
> HDD/BIGFILES/IMASCOARSESTOCK/SMOS/_NRTSM003D025A_ALL_2013.nc has 4
> dimensions:"
> [1] "time Size: 365"
> [1] "lat Size: 44"
> [1] "lon Size: 62"
> [1] "time_strlen Size: 20"
> [1] "------------------------"
> [1] "file /media/alobo/FREECOM
> HDD/BIGFILES/IMASCOARSESTOCK/SMOS/_NRTSM003D025A_ALL_2013.nc has 4
> variables:"
> [1] "int L2_Points[lon,lat,time] Longname:Number of Measures Missval:0"
> [1] "float SM[lon,lat,time] Longname:Surface soil moisture Missval:-999"
> [1] "float SM_DQX[lon,lat,time] Longname:Surface soil moisture_dqx
> Missval:-999"
> [1] "float VARIANCE_SM[lon,lat,time] Longname:Variance of Surface
> soil moisture Missval:-999"
>
> Is there a way to select the desired variable within brick() ?
> Or should I use get.var.ncdf() and then transform to raster?
> (the only problem in this case is that I have to rotate etc, while
> brick() does it all in the first case)
>
> Thanks
>
> Agus
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
[[alternative HTML version deleted]]
More information about the R-sig-Geo
mailing list