[R-sig-Geo] extract data from multilayer nc file

Antonio Silva @o||nto@|@t @end|ng |rom gm@||@com
Thu May 30 21:40:53 CEST 2019


Thanks a lot Sarah. I ran your examples. Since I use Linux Ubuntu command
lines just worked fine.

I will learn more about NCO.

Once more thanks for your help.

All the best

A.O.

Em qui, 30 de mai de 2019 às 13:12, Sarah Goslee <sarah.goslee using gmail.com>
escreveu:

> Hi Antonio,
>
> I work with NetCDF files a lot, and I find it enormously easier to
> split up multidimensional files before importing them into R.
>
> I use NCO for this (http://nco.sourceforge.net/) but I'm sure there
> are other options. I'm afraid I have no idea how well that works on
> windows.
>
> For your sample file, here's how you could split it by depth and by
> variable.
>
> ncks -d depth,0,0 -v to dataset-armor-3d-rep-monthly_1559213337443.nc
> vo50.nc
> ncks -d depth,0,0 -v so dataset-armor-3d-rep-monthly_1559213337443.nc
> so50.nc
>
> ncks -d depth,1,1 -v to dataset-armor-3d-rep-monthly_1559213337443.nc
> vo75.nc
> ncks -d depth,1,1 -v so dataset-armor-3d-rep-monthly_1559213337443.nc
> so75.nc
>
> > library(raster)
> Loading required package: sp
> > vo75 <- stack("vo75.nc")
> Loading required namespace: ncdf4
> > dim(vo75)
> [1] 29 41 12
>
> Sarah
>
> On Thu, May 30, 2019 at 10:24 AM Antonio Silva <aolinto.lst using gmail.com>
> wrote:
> >
> > Hello all,
> >
> > I want to extract monthly sea water temperature and salinity (50 and 75 m
> > depth) for a given area.
> >
> > To do so I downloaded dataset-armor-3d-rep-monthly (product
> > MULTIOBS_GLO_PHY_REP_015_002) from Copernicus Marine environment
> monitoring
> > service (http://marine.copernicus.eu/). A sample file can be found at
> > https://app.box.com/s/f8yyf3jn9kye1htqc7aktjk38jp39yrm.
> >
> > I also prepared a shapefile delimiting the area of interest (
> > https://app.box.com/s/ciq76w7918zir3hu89l8d3y9dn3csuxp).
> >
> > Some time ago I dealt with monthly salinity data files, that is, with
> only
> > one variable. I prepared a script and made it available at
> > https://gist.github.com/aolinto/59e43cdbac3ff3e0cd5eb2eab5efcbc4.
> >
> > Now I have a nc file with several variables (so and to) and each one has
> 4
> > dimensions (time (for each month), lat, lon and depth (50 and 75 m)).
> >
> > For a file with 3 dimensions per variable I write
> > rst.data <- stack("dataset-sss-ssd-rep-monthly_sos_2008_2017.nc
> ",varname="sos")
> >
> >
> > But this turn I receive the message
> > > rst.data <- stack("dataset-armor-3d-rep-monthly_1559213337443.nc
> ",varname="to")
> > # indicate the nc file
> > Warning messages:
> > 1: In .stackCDF(x, varname = varname, bands = bands) :
> >   to has 4 dimensions, I am using the last one
> > 2: In .rasterObjectFromCDF(x, type = objecttype, band = band, ...) :
> >   "level" set to 1 (there are 2 levels)
> >
> > I tried several commands (bands, layers) but I couldn't make a stack to
> 50
> > and another to 75 data.
> >
> > I appreciate any help.
> >
> > Best regards,
> >
> > Antônio Olinto
> > Instituto de Pesca (Fisheries Institute)
> > São Paulo, Brasil
> >
> >         [[alternative HTML version deleted]]
> >
> > _______________________________________________
> > R-sig-Geo mailing list
> > R-sig-Geo using r-project.org
> > https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
>
>
> --
> Sarah Goslee (she/her)
> http://www.numberwright.com
>

	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list