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

Antonio Silva @o||nto@|@t @end|ng |rom gm@||@com
Thu May 30 16:23:42 CEST 2019


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]]



More information about the R-sig-Geo mailing list