@ -0,0 +1,75 @@ |
|||
set_names <- function(object = nm, nm) { |
|||
names(object) <- nm |
|||
object |
|||
} |
|||
|
|||
set_names( |
|||
c("alaska", "centgrtlakes_radaronly", "hawaii_radaronly", |
|||
"latest_radaronly", "northeast_radaronly", "northrockies_radaronly", |
|||
"pacnorthwest_radaronly", "pacsouthwest_radaronly", |
|||
"southeast_radaronly", "southmissvly_radaronly", |
|||
"southplains_radaronly", "southrockies_radaronly", |
|||
"uppermissvly_radaronly"), |
|||
|
|||
c("alaska", "centgrtlakes", "hawaii", |
|||
"latest", "northeast", "northrockies", |
|||
"pacnorthwest", "pacsouthwest", |
|||
"southeast", "southmissvly", |
|||
"southplains", "southrockies", |
|||
"uppermissvly") |
|||
|
|||
) -> .reg_trans |
|||
|
|||
#' Read latest NWS regional or ConUS radar mosaics as a `stars` object |
|||
#' |
|||
#' @param regional_mosaic one of the supported mosaics from [the official NWS list](https://radar.weather.gov/ridge/): |
|||
#' - "`alaska`": Alaska |
|||
#' - "`centgrtlakes`": Central Great Lakes |
|||
#' - "`hawaii`": Hawaii |
|||
#' - "`latest`": ConUS |
|||
#' - "`northeast`": Northeast |
|||
#' - "`northrockies`": Northern Rockies |
|||
#' - "`pacnorthwest`": Pacific Northwest |
|||
#' - "`pacsouthwest`": Pacific Southwest |
|||
#' - "`southeast`": Southeast |
|||
#' - "`southmissvly`": Southern Mississippi Valley |
|||
#' - "`southplains`": Southern Plains |
|||
#' - "`southrockies`": Southern Rockies |
|||
#' - "`uppermissvly`": Upper Mississippi Valley |
|||
#' @param quiet passed on to [utils::download.file()] |
|||
#' @return `stars` object with the raster composite with a CRS of EPSG:4326 |
|||
#' @export |
|||
latest_radar <- function(regional_mosaic = c("alaska", "centgrtlakes", "hawaii", |
|||
"latest", "northeast", "northrockies", |
|||
"pacnorthwest", "pacsouthwest", |
|||
"southeast", "southmissvly", |
|||
"southplains", "southrockies", |
|||
"uppermissvly"), quiet = TRUE) { |
|||
|
|||
regional_mosaic <- match.arg(tolower(regional_mosaic[1]), c("alaska", "centgrtlakes", "hawaii", |
|||
"latest", "northeast", "northrockies", |
|||
"pacnorthwest", "pacsouthwest", |
|||
"southeast", "southmissvly", |
|||
"southplains", "southrockies", |
|||
"uppermissvly")) |
|||
regional_mosaic <- .reg_trans[[regional_mosaic]] |
|||
|
|||
td <- tempdir() |
|||
on.exit(unlink(td)) |
|||
|
|||
download.file( |
|||
c( |
|||
sprintf("https://radar.weather.gov/ridge/Conus/RadarImg/%s.gif", regional_mosaic), |
|||
sprintf("https://radar.weather.gov/ridge/Conus/RadarImg/%s.gfw", regional_mosaic) |
|||
), |
|||
file.path(td, paste(regional_mosaic, c(".gif", ".gfw"), sep = "")), |
|||
method = "libcurl", |
|||
quiet = quiet |
|||
) |
|||
|
|||
out <- stars::read_stars(file.path(td, sprintf("%s.gif", regional_mosaic))) |
|||
|
|||
sf::st_set_crs(out, 4326) |
|||
|
|||
} |
|||
|
Before Width: | Height: | Size: 972 KiB After Width: | Height: | Size: 1.1 MiB |
Before Width: | Height: | Size: 1.6 MiB After Width: | Height: | Size: 1.8 MiB |
Before Width: | Height: | Size: 1.2 MiB After Width: | Height: | Size: 1.0 MiB |
After Width: | Height: | Size: 40 KiB |
@ -0,0 +1,39 @@ |
|||
% Generated by roxygen2: do not edit by hand |
|||
% Please edit documentation in R/latest_radar.R |
|||
\name{latest_radar} |
|||
\alias{latest_radar} |
|||
\title{Read latest NWS regional or ConUS radar mosaics as a \code{stars} object} |
|||
\usage{ |
|||
latest_radar( |
|||
regional_mosaic = c("alaska", "centgrtlakes", "hawaii", "latest", "northeast", |
|||
"northrockies", "pacnorthwest", "pacsouthwest", "southeast", "southmissvly", |
|||
"southplains", "southrockies", "uppermissvly"), |
|||
quiet = TRUE |
|||
) |
|||
} |
|||
\arguments{ |
|||
\item{regional_mosaic}{one of the supported mosaics from \href{https://radar.weather.gov/ridge/}{the official NWS list}: |
|||
\itemize{ |
|||
\item "\code{alaska}": Alaska |
|||
\item "\code{centgrtlakes}": Central Great Lakes |
|||
\item "\code{hawaii}": Hawaii |
|||
\item "\code{latest}": ConUS |
|||
\item "\code{northeast}": Northeast |
|||
\item "\code{northrockies}": Northern Rockies |
|||
\item "\code{pacnorthwest}": Pacific Northwest |
|||
\item "\code{pacsouthwest}": Pacific Southwest |
|||
\item "\code{southeast}": Southeast |
|||
\item "\code{southmissvly}": Southern Mississippi Valley |
|||
\item "\code{southplains}": Southern Plains |
|||
\item "\code{southrockies}": Southern Rockies |
|||
\item "\code{uppermissvly}": Upper Mississippi Valley |
|||
}} |
|||
|
|||
\item{quiet}{passed on to \code{\link[utils:download.file]{utils::download.file()}}} |
|||
} |
|||
\value{ |
|||
\code{stars} object with the raster composite with a CRS of EPSG:4326 |
|||
} |
|||
\description{ |
|||
Read latest NWS regional or ConUS radar mosaics as a \code{stars} object |
|||
} |