-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path4_2_Exporting_to_netCDF.R
More file actions
49 lines (31 loc) · 1.02 KB
/
4_2_Exporting_to_netCDF.R
File metadata and controls
49 lines (31 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# instalacion de 'loadeR.2nc' ----
# library(devtools)
# install_github("SantanderMetGroup/loadeR.2nc")
# fin ---
library(raster)
library(loadeR.2nc)
# Lectura de datos ----
data(tx) # A climate4R grid
spatialPlot(climatology(tx), backdrop.theme = "countries", color.theme = "RdYlBu")
# fin ---
# Creacion netcdf ----
# Name of output file:
fileName <- "tasmax_WFDEI_JJA_W2001_2010.nc4"
# Including a global attribute:
globalAttributeList <- list("institution" = "SantanderMetGroup, http://www.meteo.unican.es/")
# Including two variable attributes:
varAttributeList <- list(var_attr1 = "one_attribute", var_attr2 = "another_attribute")
# Create file:
grid2nc(data = tx,
NetCDFOutFile = fileName,
missval = 1e20,
prec = "float",
globalAttributes = globalAttributeList,
varAttributes = varAttributeList)
# fin ---
# archivo netcdf creado ----
r <- raster('tasmax_WFDEI_JJA_W2001_2010.nc4')
plot(r)
# fin ---
# fuente
# https://github.com/SantanderMetGroup/loadeR/wiki/Exporting-to-netCDF