[R-sig-Geo] extract data from multilayer nc file
@o||nto@|@t @end|ng |rom gm@||@com
Thu May 30 16:23:42 CEST 2019
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
I also prepared a shapefile delimiting the area of interest (
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
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
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.
Instituto de Pesca (Fisheries Institute)
São Paulo, Brasil
[[alternative HTML version deleted]]
More information about the R-sig-Geo