-
-
Notifications
You must be signed in to change notification settings - Fork 288
/
r3.out.netcdf.html
264 lines (231 loc) · 12.6 KB
/
r3.out.netcdf.html
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
<h2>DESCRIPTION</h2>
The module <em>r3.out.netcdf</em> exports a 3D raster map as netCDF file.
Maps are valid 3D raster maps in the current mapset search path. The
<em>output</em> parameter is the name of a netCDF file that will be
written in the current working directory. The module is sensitive
to mapset region settings (set with <em>g.region</em>) and the vertical unit settings
of the 3D raster map. The vertical unit can be set with <a href="r3.support.html">r3.support</a>.
<h2>NOTES</h2>
The resulting netCDF file will have time as third dimension in case a temporal
vertical unit is specified for the input map, otherwise the third dimension is assumed as spatial.
If the 3D raster map has a time stamp with absolute time, the start time will be
used as starting point for the netCDF time series. If the absolute time stamp is missing
the date "Jan. 01. 1900 00:00:00" will be used as default. In case of relative time stamp no start time
is set in the netCDF file. The number of depths of the 3D raster map are the number of time slices
in the netCDF file. You can use <em>t.rast.to.rast3</em> to convert a
space time raster dataset into a 3D raster map representing a space time voxel
cube, then export the raster time series as netCDF file.
<p>
Spatial coordinates are exported as cell centered coordinates. The projection can be optionally stored
in the metadata as <em>crs</em> attributes .
The netCDF projection metadata storage follows the spatial_ref GDAL/netCDF suggestion
<a href="http://www.gdal.org/frmt_netcdf.html">here</a>
and the netCDF CF 1.6 convention
<a href="http://cf-pcmdi.llnl.gov/documents/cf-conventions/1.6/cf-conventions.html#coordinate-system">here</a>
using WKT projection information. Additional a PROJ string is
stored in the <em>crs</em> attribute section.
The export of projection parameters is suppressed when the XY-projection is set.
<p>
The range of the 3D raster map is set in the netCDF output file. Optionally a the netCDF missing value and
_FillValue can be set using the <em>null</em> option. As default the netCDF floating point _FillValues are used
to fill empty cell.
<p>
The netCDF library must be installed on the system and activated at configuration time to compile this module.
<h2>EXAMPLES</h2>
<div class="code"><pre>
g.region s=-90 n=90 w=-180 e=180 b=0 t=5 res=10 res3=10 tbres=1 -p3
#####################################################################
# We create a simple volume map with floating point values
#####################################################################
r3.mapcalc --o expr="volume_float = float(col() + row() + depth())"
r3.info volume_float
+----------------------------------------------------------------------------+
| Layer: volume_float Date: Thu Jun 14 08:40:56 2012 |
| Mapset: PERMANENT Login of Creator: soeren |
| Location: TestLL |
| DataBase: /1/soeren/grassdata |
| Title: volume_float |
| Units: none |
| Vertical unit: units |
| Timestamp: none |
|----------------------------------------------------------------------------|
| |
| Type of Map: 3d cell Number of Categories: 0 |
| Data Type: FCELL |
| Rows: 18 |
| Columns: 36 |
| Depths: 5 |
| Total Cells: 3240 |
| Total size: 10114 Bytes |
| Number of tiles: 1 |
| Mean tile size: 10114 Bytes |
| Tile size in memory: 12960 Bytes |
| Number of tiles in x, y and z: 1, 1, 1 |
| Dimension of a tile in x, y, z: 36, 18, 5 |
| |
| Projection: Latitude-Longitude (zone 0) |
| N: 90N S: 90S Res: 10 |
| E: 180E W: 180W Res: 10 |
| T: 5 B: 0 Res: 1 |
| Range of data: min = 3 max = 59 |
| |
| Data Source: |
| |
| |
| |
| Data Description: |
| generated by r3.mapcalc |
| |
| Comments: |
| r3.mapcalc expression="volume_float = float(col() + row() + depth())" |
| |
+----------------------------------------------------------------------------+
#####################################################################
# We use the netCDF ncdump tool to have a look at the header
# and coordinates of the exported netCDF file
#####################################################################
r3.out.netcdf --o input=volume_float output=test_float.nc
ncdump -c test_float.nc
netcdf test_float {
dimensions:
longitude = 36 ;
latitude = 18 ;
z = 5 ;
variables:
float longitude(longitude) ;
longitude:units = "degrees_east" ;
longitude:long_name = "Longitude values" ;
longitude:standard_name = "longitude" ;
longitude:axis = "X" ;
float latitude(latitude) ;
latitude:units = "degrees_north" ;
latitude:long_name = "Latitude values" ;
latitude:standard_name = "latitude" ;
latitude:axis = "Y" ;
float z(z) ;
z:units = "meter" ;
z:long_name = "z coordinate of projection" ;
z:standard_name = "projection_z_coordinate" ;
z:positive = "up" ;
z:axis = "Z" ;
float volume_float(z, latitude, longitude) ;
volume_float:valid_min = 3.f ;
volume_float:valid_max = 59.f ;
// global attributes:
:Conventions = "CF-1.5" ;
:history = "GRASS GIS 7 netCDF export of r3.out.netcdf" ;
data:
longitude = -175, -165, -155, -145, -135, -125, -115, -105, -95, -85, -75,
-65, -55, -45, -35, -25, -15, -5, 5, 15, 25, 35, 45, 55, 65, 75, 85, 95,
105, 115, 125, 135, 145, 155, 165, 175 ;
latitude = 85, 75, 65, 55, 45, 35, 25, 15, 5, -5, -15, -25, -35, -45, -55,
-65, -75, -85 ;
z = 0.5, 1.5, 2.5, 3.5, 4.5 ;
}
#####################################################################
# Exporting the projection specific settings and a null value
#####################################################################
r3.out.netcdf --o -p null=-1 input=volume_float output=test_float.nc
ncdump -c test_float.nc
netcdf test_float {
dimensions:
longitude = 36 ;
latitude = 18 ;
z = 5 ;
variables:
char crs ;
crs:crs_wkt = "GEOGCS[\"wgs84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS_1984\",6378137,298.257223563]],PRIMEM[\"Greenwich\",0],UNIT[\"degree\",0.0174532925199433]]" ;
crs:spatial_ref = "GEOGCS[\"wgs84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS_1984\",6378137,298.257223563]],PRIMEM[\"Greenwich\",0],UNIT[\"degree\",0.0174532925199433]]" ;
crs:crs_proj4 = " +proj=longlat +no_defs +a=6378137 +rf=298.257223563 +towgs84=0.000,0.000,0.000" ;
float longitude(longitude) ;
longitude:units = "degrees_east" ;
longitude:long_name = "Longitude values" ;
longitude:standard_name = "longitude" ;
longitude:axis = "X" ;
float latitude(latitude) ;
latitude:units = "degrees_north" ;
latitude:long_name = "Latitude values" ;
latitude:standard_name = "latitude" ;
latitude:axis = "Y" ;
float z(z) ;
z:units = "meter" ;
z:long_name = "z coordinate of projection" ;
z:standard_name = "projection_z_coordinate" ;
z:positive = "up" ;
z:axis = "Z" ;
float volume_float(z, latitude, longitude) ;
volume_float:valid_min = 3.f ;
volume_float:valid_max = 59.f ;
volume_float:missing_value = -1.f ;
volume_float:_FillValue = -1.f ;
volume_float:grid_mapping = "crs" ;
// global attributes:
:Conventions = "CF-1.5" ;
:history = "GRASS GIS 7 netCDF export of r3.out.netcdf" ;
data:
longitude = -175, -165, -155, -145, -135, -125, -115, -105, -95, -85, -75,
-65, -55, -45, -35, -25, -15, -5, 5, 15, 25, 35, 45, 55, 65, 75, 85, 95,
105, 115, 125, 135, 145, 155, 165, 175 ;
latitude = 85, 75, 65, 55, 45, 35, 25, 15, 5, -5, -15, -25, -35, -45, -55,
-65, -75, -85 ;
z = 0.5, 1.5, 2.5, 3.5, 4.5 ;
}
#####################################################################
# Assigning time as vertical unit and setting an absolute time stamp
#####################################################################
r3.timestamp map=volume_float date='1 Jan 2001/5 Jan 2001'
r3.support map=volume_float vunit="days"
r3.out.netcdf --o -p null=-1 input=volume_float output=test_float.nc
ncdump -c test_float.nc
netcdf test_float {
dimensions:
longitude = 36 ;
latitude = 18 ;
time = 5 ;
variables:
char crs ;
crs:crs_wkt = "GEOGCS[\"wgs84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS_1984\",6378137,298.257223563]],PRIMEM[\"Greenwich\",0],UNIT[\"degree\",0.0174532925199433]]" ;
crs:spatial_ref = "GEOGCS[\"wgs84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS_1984\",6378137,298.257223563]],PRIMEM[\"Greenwich\",0],UNIT[\"degree\",0.0174532925199433]]" ;
crs:crs_proj4 = " +proj=longlat +no_defs +a=6378137 +rf=298.257223563 +towgs84=0.000,0.000,0.000" ;
float longitude(longitude) ;
longitude:units = "degrees_east" ;
longitude:long_name = "Longitude values" ;
longitude:standard_name = "longitude" ;
longitude:axis = "X" ;
float latitude(latitude) ;
latitude:units = "degrees_north" ;
latitude:long_name = "Latitude values" ;
latitude:standard_name = "latitude" ;
latitude:axis = "Y" ;
int time(time) ;
time:units = "days since 2001-01-01 00:00:00" ;
time:long_name = "Time in days" ;
time:calendar = "gregorian" ;
time:positive = "up" ;
time:axis = "T" ;
float volume_float(time, latitude, longitude) ;
volume_float:valid_min = 3.f ;
volume_float:valid_max = 59.f ;
volume_float:missing_value = -1.f ;
volume_float:_FillValue = -1.f ;
volume_float:grid_mapping = "crs" ;
// global attributes:
:Conventions = "CF-1.5" ;
:history = "GRASS GIS 7 netCDF export of r3.out.netcdf" ;
data:
longitude = -175, -165, -155, -145, -135, -125, -115, -105, -95, -85, -75,
-65, -55, -45, -35, -25, -15, -5, 5, 15, 25, 35, 45, 55, 65, 75, 85, 95,
105, 115, 125, 135, 145, 155, 165, 175 ;
latitude = 85, 75, 65, 55, 45, 35, 25, 15, 5, -5, -15, -25, -35, -45, -55,
-65, -75, -85 ;
time = 0, 1, 2, 3, 4 ;
}
</pre></div>
<h2>SEE ALSO</h2>
<em>
<a href="t.rast.to.rast3.html">t.rast.to.rast3</a>,
<a href="r3.out.ascii.html">r3.in.ascii</a>,
<a href="g.region.html">g.region</a>
</em>
<h2>AUTHORS</h2>
Sören Gebbert