【R】気象データの表示(US)

アメリカの気象データの表示をしてみます。こちらのサイトを参考にさせていただきました。

まずは、アリゾナの地図。

library(sf)           
library(raster)        
library(RNetCDF)       
library(exactextractr) 
library(rasterVis)
library(climateR)
library(AOI)

AOI     = aoi_get(state = "AZ")
(extent = st_bbox(AOI))

(crs    = st_crs(AOI)$proj4string)

plot(AOI$geometry, border  = "darkred",lwd = 2)
plot(st_as_sfc(extent), add = TRUE,  lwd = 3)

降水量

AOI::aoi_get(state = "AZ") %>% 
  AOI::aoi_map(returnMap = TRUE)

catolgue = "http://thredds.northwestknowledge.net:8080/thredds/dodsC/"
cdm = "agg_met_pr_1979_CurrentYear_CONUS.nc"
url = paste0(catolgue, cdm, "#fillmismatch")

(nc   = RNetCDF::open.nc(url))

X    = RNetCDF::var.get.nc(nc, "lon")
Y    = RNetCDF::var.get.nc(nc, "lat")
time = RNetCDF::var.get.nc(nc, "day")
length(X)

(xmin = which.min(abs(sort(X) - extent$xmin)) - 1)
(xmax = which.min(abs(sort(X) - extent$xmax)) - 1)
(ymin = which.min(abs(sort(Y) - extent$ymin)) - 1)
(ymax = which.min(abs(sort(Y) - extent$ymax)) - 1)

time = as.Date("2018-01-19") - as.Date("1979-01-01") 
(time = as.numeric(time))

url = paste0(
  catolgue,
  cdm,
  "?precipitation_amount",
  "[", time, ":1:", time, "]",
  "[", ymin, ":1:", ymax, "]",
  "[", xmin, ":1:", xmax, "]",
  "#fillmismatch")
(nc    = RNetCDF::open.nc(url))

rain  = RNetCDF::var.get.nc(nc, "precipitation_amount", unpack = TRUE)

dim(rain)

plot(raster::raster(rain))

ハリケーンによる降水量

harvey = getGridMET(aoi_get(state = "TX"), 
                    param = "prcp", startDate = "2017-08-24", endDate = "2017-08-31")

levelplot(harvey$prcp, par.settings = BTCTheme, main = "Hurricane Harvey")

Add a Comment

メールアドレスが公開されることはありません。