readDWD.grib2 | R Documentation |
read gridded numerical weather prediction data.
Intended to be called via readDWD()
.
readDWD.grib2(file, pack = "terra", bargs = NULL, quiet = rdwdquiet(), ...)
file |
Name of file on harddrive, like e.g. cosmo-d2_germany_regular-lat-lon_single-level_2021010100_005_T_2M.grib2.bz2 |
pack |
Char: package used for reading. One of "terra" or "stars". "rgdal" (for the deprecated cosmo-d2 data) is no longer available, see issue. DEFAULT: "terra" |
bargs |
Named list of arguments passed to
|
quiet |
Silence readGDAL completely, including warnings on
discarded ellps / datum.
DEFAULT: FALSE through |
... |
Further arguments passed to |
terra or stars object, depending on pack
Berry Boessenkool, berry-b@gmx.de, Jan 2021.
readDWD()
https://www.dwd.de/EN/ourservices/nwp_forecast_data/nwp_forecast_data.html
https://www.dwd.de/EN/aboutus/it/functions/Teasergroup/grib.html
## Not run: # Excluded from CRAN checks, but run in localtests
nwp_t2m_base <- "ftp://opendata.dwd.de/weather/nwp/icon-d2/grib/15/soiltyp"
nwp_urls <- indexFTP("", base=nwp_t2m_base, dir=tempdir())
# for p instead of soiltyp, icosahedral_model-level files fail with GDAL errors,
# see https://github.com/brry/rdwd/issues/28
# regular-lat-lon_pressure-level files work with pack="terra" or "stars"
nwp_file <- dataDWD(tail(nwp_urls,1), base=nwp_t2m_base, dir=tempdir(),
joinbf=TRUE, dbin=TRUE, read=FALSE)
nwp_data <- readDWD(nwp_file)
terra::plot(nwp_data)
addBorders() # the projection seems to be perfectly good :)
# index of GRIB files
if(FALSE){ # indexing takes about 6 minutes!
grib_base <- "ftp://opendata.dwd.de/weather/nwp/icon-d2/grib"
grib_files <- indexFTP("", base=grib_base, dir=tempdir())
for(f in unique(substr(grib_files, 1,3))) print(grib_files[which(substr(grib_files, 1,3)==f)[1]])
View(data.frame(grep("regular",grib_files, value=TRUE)))
}
# Project_TRY bz2 netcdf data:
url <- "hourly/Project_TRY/air_temperature_mean/TT_201102.nc.bz2" # 97 MB
file <- dataDWD(url, base=gridbase, joinbf=TRUE, dir=tempdir(), read=FALSE)
nc <- readDWD(file) # should also be using readDWD.grib2
# Setting layer=1:2 takes 4 minutes, just go one at a time, I guess:
ncp <- plotRadar(nc, main=paste(terra::longnames(nc), terra::time(nc)), layer=1,
col=berryFunctions::seqPal(), proj="nc", extent="nc")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.