Converting RasterStack into Netcdf File

Hello,

I´ve been trying to convert a RasterStack class into a NetCDF file using the writeRaster function. However, I have noticed that the converted nc file has two variables, one of them is the src string. Is this correct? how can I eliminate this variable if is not correct

Here is what I have done so far and here is the netcdf file

myStackRaster

class      : RasterStack 
dimensions : 97, 107, 10379, 6  (nrow, ncol, ncell, nlayers)
resolution : 0.05, 0.05  (x, y)
extent     : -58.45, -53.1, -34.95, -30.1  (xmin, xmax, ymin, ymax)
crs        : +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0 
names      : X2020.06.21, X2020.06.26, X2020.07.01, X2020.07.06, X2020.07.11, X2020.07.16 
min values :    15.17224,    16.62855,    17.57079,    25.34024,    37.90452,    35.48506 
max values :    56.56909,    63.15136,    64.47987,    64.54590,    83.37997,    87.15372 
time        : 2020-06-21, 2020-06-26, 2020-07-01, 2020-07-06, 2020-07-11, 2020-07-16 

output.nc <- "test.nc"

myRaster <- writeRaster(RasterStack,output.nc,overwrite = TRUE,format="CDF", varname="percentile")

nc <- nc_open(output.nc)

print(paste("The file has",nc$nvars,"variables,",nc$ndims,"dimensions and",nc$natts,"NetCDF attributes"))
attributes(nc$var)$names

"The file has 2 variables, 3 dimensions and 3 NetCDF attributes"

attributes(nc$var)$names

"crs"        "percentile"

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.