-
Notifications
You must be signed in to change notification settings - Fork 0
/
02_gridded_data.qmd
76 lines (58 loc) · 2.5 KB
/
02_gridded_data.qmd
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
```{r}
```
---
title: "02_gridded_data"
format: html
editor: visual
---
# 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)
```
### 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}
# 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)
------------------------------------------------------------------------
### 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)