scale_fill_rradar: Continuous fill scale for use with NWS raster radar data

Description Usage Arguments Value Examples

View source: R/scale-rradar.R

Description

The dBZ values associated with the base reflectivity radar images/data represent the strength of the energy returned to the radar from the precipitation. Values lower than 20 dBZ are generally when there is actual light rain. The NWS tends to use a light gray alpha for values below ~5 dBZ since there are particles in the air but they really aren't something that constitutes precipitation.

This {ggplot2} continuous fill scale is an adaptation of the {viridis} color palette scales where the viridis scale mappings only start when dBZ values are around 5 dBZ. Values lower than that receive light gray with a 5% alpha (see the low_dbz parameter).

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
scale_fill_rradar(
  option = "plasma",
  direction = -1,
  name = "dBZ",
  na.value = "#00000000",
  limits = c(-30, 70),
  breaks = seq(-30, 70, 5),
  low_dbz = "#00000010",
  ...
)

Arguments

option, direction

passed on to viridis::viridis_pal(); defaults to "plasma" and -1, respectively.

name

The name of the scale

na.value

Missing values will be replaced with this value. Defaults to a fully transparent color.

limits

scale limits; defaults to NWS dBZ limits -30, 70

breaks

scale breaks; defaults to the NWS every 5 sequence from -30 to 70

low_dbz

color to be uses the dbZ values are lower than ~5 dBZ. Defaults to "#00000010"

...

passed on to ggplot2::scale_fill_gradientn()

Value

a {ggplot2} continuous fill scale

Examples

 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
## Not run: 
library(sf)
library(stars)
library(rradar)
library(rnaturalearth)
library(hrbrthemes)
library(tidyverse)

us <- ne_states(country = "united states of america", returnclass = "sf")

ne_radar <- latest_radar("northeast")

ne_us <- st_crop(us, st_bbox(ne_radar))

ggplot() +
  geom_sf(data = ne_us, size = 0.125, fill = '#fefefe') +
  geom_stars(data = ne_radar) +
  coord_sf(datum = NA) +
  scale_fill_rradar() +
  labs(
    x = NULL, y = NULL,
    title = "NWS Radar Mosaic — Northeast Sector",
    subtitle = "1538 UTC 2019-12-07"
  ) +
  theme_ipsum_es(grid="") +
  theme(legend.key.height = unit(5, "lines"))

## End(Not run)

hrbrmstr/rradar documentation built on Dec. 23, 2019, 10:18 p.m.