-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathberkeley.R
More file actions
35 lines (23 loc) · 814 Bytes
/
berkeley.R
File metadata and controls
35 lines (23 loc) · 814 Bytes
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
url <- "https://berkeley-earth-temperature-hr.s3.amazonaws.com/Gridded/Australasia_TAVG_Gridded_1.nc"
file <- here("data/Australasia_TAVG_Gridded_1.nc")
library(ncdf4)
library(raster)
library(lubridate)
b <- brick(file)
proj4string(b)=CRS("+proj=longlat +datum=WGS84")
b.df = raster::as.data.frame(b, xy = TRUE)
plot(b[[2065]])
#using stars --- slow but logical and works
library(ncmeta)
library(stars)
library(lubridate)
data <- read_ncdf(file, var="temperature", make_time = FALSE)
data <- data %>%
st_as_sf() %>%
mutate(grid=row_number()) %>%
pivot_longer(cols=-c(grid, geometry),
names_to="date",
names_prefix="temperature\\.V",
values_to="temp") %>%
mutate(date = as.numeric(date),
date = as.Date("1850-01-01") + months(date))