I. SpatRaster 処理あれこれ

解像度を上げるには

[例] NOAA GlobalTemp 6.1.0
https://www.ncei.noaa.gov/products/land-based-station/noaa-global-temp

これのグリッドデータ:

pacman::p_load(
  tidyverse,
  terra,
  rvest)

URL <- "https://www.ncei.noaa.gov/data/noaa-global-surface-temperature/v6.1/access/gridded/"
ncFiles <- read_html(URL) |>
  rvest::html_elements("a") |>
  rvest::html_text2() |> 
  as_tibble() |> 
  filter(str_detect(value, "nc")) |> 
  pull()

nc.url <- paste0(URL, tail(ncFiles, 1))
nc.filepath <- file.path(tempdir(), tail(ncFiles, 1))
download.file(nc.url, 
              destfile = nc.filepath, mode = "wb")

ダウンロードが完了したら、SpatRasterとして読み込み、解像度を確認した後、最初のレイヤーをプロットしてみる。

noaa.raster <- rast(nc.filepath)

res(noaa.raster)
## [1] 5 5
plot(noaa.raster[[1]])

解像度を5°×5°から1°×1°に上げる。

noaa.raster.hires <- disagg(noaa.raster[[1]], 
                            fact = 5, method = "bilinear")

res(noaa.raster.hires)
## [1] 1 1
plot(noaa.raster.hires)