-
Notifications
You must be signed in to change notification settings - Fork 0
/
02_gridded_data.Rmd
95 lines (70 loc) · 3 KB
/
02_gridded_data.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
---
title: "02_gridded_data"
output:
github_document:
df_print: paged
---
# Gridded datasets
ERDDAP has a seperate mechanism for gridded data, like satellite and model/reanalysis products. This is called griddap.
```{r, echo = FALSE}
# load necessary libraries
library(dplyr)
library(ggplot2)
library(plotdap)
library(rerddap)
library(rerddapXtracto)
```
### Specify server and protocol
Here we use a hi-res SST product from JPL via the coastwatch server https://coastwatch.pfeg.noaa.gov/erddap/griddap/jplMURSST41.html
```{r}
# use 'rerddap::griddap()' to download MUR data
wcn_erddap <- "https://coastwatch.pfeg.noaa.gov/erddap"
dataset_id <- 'jplMURSST41'
mur_info <- info(dataset_id, url = wcn_erddap)
stride <- c(1, 10, 10)
mur <- griddap( mur_info,
fields = 'analysed_sst',
stride = stride,
time = c('last','last'),
longitude = c(-179.99, 180),
latitude = c(-89.99, 89.99)
)
# use 'plotdap::add_griddap()' to make quick plot of the data
p <- plotdap()
p <- add_griddap(p, mur, ~analysed_sst, fill = "thermal", maxpixels = 100000)
p
```
Gridded datasets can be very large. By default, erddapy returns only the most recent time slice of a dataset. This behaviour can be changed by adjusting the constraints, much like with tabledap. The mechanism for subsetting griddap data is a little more complicated, as the data are multi-dimensional.
Let's zoom in on the Gulf Stream and take a few time slices. To achieve this, we modify the constraints. We will tighten the lon/lat to a window of interest and request a wider timespan of data, taking every 30th day over the last few years
```{r, echo = TRUE, eval = FALSE}
# use 'rerddap::griddap()' to get the data
mur <- griddap( mur_info,
fields = 'analysed_sst',
stride = c(30, 1, 1),
time = c('2023-01-01','2023-05-01'),
longitude = c(-90, -30),
latitude = c(25, 45)
)
# use 'plotdap::add_griddap()' to do an animated mapping of the data
# this can take awhile to render
p <- plotdap()
add_griddap(p, mur, ~analysed_sst, fill = "thermal", maxpixels = 30000, time = identity, animate = TRUE)
```
![](mur_animation.gif)
### extra example: low-res topography
```{r, warning = FALSE}
wcn_erddap <- "https://coastwatch.pfeg.noaa.gov/erddap/"
bathy_info <- info("etopo180", url = wcn_erddap)
latitude <- c(20, 60)
longitude <- c(-90, -30)
bathy <- rxtracto_3D(bathy_info,
parameter = 'altitude',
ycoord = latitude,
xcoord = longitude,
)
plotBBox(bathy, plotColor = 'topo', maxpixels = 50000)
```
------------------------------------------------------------------------
### References
coastwatch ERDDAP https://coastwatch.pfeg.noaa.gov/erddap/index.html
For more information on how erddapy deals with griddap, see the [erddapy documentation example notebook](https://ioos.github.io/erddapy/01a-griddap-output.html)