'How to collapse NetCDF by time and export it as raster in R

Im working with NetCDF files provided by the Copernicus Climate Change service. The data is given on daily level in a dataset containing 16 years from 1995 to 2010. I would like to collapse the dataset into yearly means for each grid (data on wind) and export single grid files for each year to continue working with them in QGIS. Until now i've tried working with the ncdf4 package to convert the NetCDF into an array. I receive the error message "vector memory exhausted (limit reached?)". I have tried reducing my dataset to single years and the general area I want to work with by using the command

Part1 <- ncvar_get( nc_data1, dname, 
                   start=c(LatIdx[1],LonIdx[1],t05[1]),
                   count=c(length(LatIdx),length(LonIdx),length(t05)))

where

LonIdx <- which( nc_data1$dim$longitude$vals > 6 & nc_data1$dim$lon$vals < 16)
LatIdx <- which( nc_data1$dim$lat$vals > 47 & nc_data1$dim$lat$vals < 56)
t05 <- which(nc_data1$dim$time$vals > 20089 & nc_data1$dim$time$vals < 20455)

(time dimension is indexed by days since 1950-01-01)

but I still get the same error message.

Can anyone help me?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source