/
GLDAS.Rmd
168 lines (106 loc) · 5.22 KB
/
GLDAS.Rmd
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
---
title: "Getting started with GLDAS data"
author: "Ibrahim N. Mohammed"
date: '`r Sys.Date()`'
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{Getting started with GLDAS data}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
```{r, include = FALSE}
knitr::opts_chunk$set(
fig.width = 7,
fig.height = 4,
collapse = TRUE,
echo = TRUE,
comment = "#>"
)
#Reading input data
dem_path <- system.file("extdata",
"DEM_TX.tif",
package = "NASAaccess")
shape_path <- system.file("extdata",
"basin.shp",
package = "NASAaccess")
library(terra)
dem <- terra::rast(dem_path)
shape <- terra::vect(shape_path)
```
_NASAaccess_ package has multiple functions such as `GLDASwat` and `GLDASpolyCentroid` that download, extract, and reformat air temperature data ('Tair_f_inst') of [GLDAS](https://hydro1.gesdisc.eosdis.nasa.gov/dods/) from [NASA servers](https://gpm.nasa.gov/data/directory) for grids within a specified watershed shapefile. The `GLDASpolyCentroid` and `GLDASswat` find the minimum and maximum air temperatures for each day at each grid within the study watershed by searching for minima and maxima over the three hours air temperature data values available for each day and grid. The `GLDASwat` and `GLDASpolyCentroid` functions output gridded air temperature (maximum and minimum) data in degrees 'C'.
Let's explore `GLDASpolyCentroid` and `GLDASswat` functions.
## Basic use
Let's use the example watersheds that we introduced with `GPMswat` and `GPMpolyCentroid`. Please visit _NASAaccess_ [GPM](GPM.html) functions for more information.
```{r, eval=FALSE, echo=TRUE}
#Reading input data
dem_path <- system.file("extdata",
"DEM_TX.tif",
package = "NASAaccess")
shape_path <- system.file("extdata",
"basin.shp",
package = "NASAaccess")
library(NASAaccess)
GLDASwat(Dir = "./GLDASwat/",
watershed = shape_path,
DEM = dem_path,
start = "2020-08-1",
end = "2020-08-3")
```
Let's examine the air temperature station file
```{r}
GLDASwat.tempMaster <- system.file('extdata/GLDASwat',
'temp_Master.txt',
package = 'NASAaccess')
GLDASwat.table<-read.csv(GLDASwat.tempMaster)
head(GLDASwat.table)
dim(GLDASwat.table)
```
`GLDASwat` generated ascii table for each available grid located within the study watershed. `GLDASwat` also generated the air temperature stations file input shown above *GLDASwat.table* (table with columns: ID, File NAME, LAT, LONG, and ELEVATION) for those selected grids that fall within the specified watershed. The [GLDAS](https://hydro1.gesdisc.eosdis.nasa.gov/dods/) dataset used here is the [GLDAS Noah Land Surface Model L4 3 hourly 0.25 x 0.25 degree V2.1](https://disc.gsfc.nasa.gov/datasets/GLDAS_NOAH025_3H_2.1/summary).
Now, let's see the location of the `GLDASwat` generated grid points
```{r}
library(ggplot2)
library(tidyterra)
ggplot(shape) +
geom_spatvector(color='red',fill=NA) +
geom_point(data=GLDASwat.table,aes(x=LONG,y=LAT))
```
We note here that `GLDASwat` has given us all the [GLDAS](https://disc.gsfc.nasa.gov/datasets/GLDAS_NOAH025_3H_2.1/summary) data grids that fall within the boundaries of the White Oak Bayou study watershed.
The time series air temperature data stored in the data tables (i.e., 2 tables) can be viewed also.
looking at air temperature reformatted data from the first grid point as listed in the air temperature station file is by
```{r}
GLDASwat.point.data <- system.file('extdata/GLDASwat',
'temp345937.txt',
package = 'NASAaccess')
#Reading data records
read.csv(GLDASwat.point.data)
```
The time series air temperature data has been written in a format that gives daily maximum and minimum air temperature in degrees 'C'.
Now, let's examine `GPMpolyCentroid`.
Using the watershed example:
```{r, eval=F, echo=T}
GLDASpolyCentroid(Dir = "./GLDASpolyCentroid/",
watershed = shape_path,
DEM = dem_path,
start = "2018-08-1",
end = "2018-08-3")
```
Now let's examine the `GLDASpolyCentroid` generated outputs
```{r}
library(ggplot2)
library(tidyterra)
GLDASpolyCentroid.tempMaster <- system.file('extdata/GLDASpolyCentroid',
'temp_Master.txt',
package = 'NASAaccess')
GLDASpolyCentroid.table<-read.csv(GLDASpolyCentroid.tempMaster)
#plot
ggplot(shape) +
geom_spatvector(color='red',fill=NA) +
geom_point(data=GLDASpolyCentroid.table,
aes(x=LONG,y=LAT)) +
coord_sf(xlim=c(-96,-95.2),ylim=c(29.7,30))
```
We note here that `GLDASpolyCentroid` has given us the [GLDAS](https://disc.gsfc.nasa.gov/datasets/GLDAS_NOAH025_3H_2.1/summary) data grid that fall within our specified watershed and assigns a pseudo air temperature gauge located at the centroid of the watershed a weighted-average daily maximum and minimum air temperature data.
## Built with
```{r}
sessionInfo()
```