rdwd (version 1.4.0)

plotRadar: plot radar products on a pretty map

Description

Convenience function to plot radar products on a pretty map. Creates a separate plot for each layer, a selection is possible.

Usage

plotRadar(
  x,
  layer = NULL,
  main = x@title,
  land = "gray80",
  sea = "cadetblue1",
  de = "grey80",
  eu = "black",
  col = berryFunctions::seqPal(),
  xlim = NULL,
  ylim = NULL,
  zlim = NULL,
  axes = TRUE,
  las = 1,
  mar = c(2.5, 3.5, 2.5, 5),
  keeppar = TRUE,
  project = TRUE,
  proj = "radolan",
  extent = "radolan",
  targetproj = "ll",
  quiet = rdwdquiet(),
  ...
)

Arguments

x

raster oject, e.g. 'dat' element of object returned by readDWD().

layer

Optional: selected layer(s) to be plotted. DEFAULT: NULL

main

Graph title(s). Use "" to suppress. Noteoutput@title is set to main! DEFAULT: x@title

land

Color of land areas in the map. DEFAULT: "gray80"

sea

Color of sea areas in the map. DEFAULT: "cadetblue1"

de

Color of Deutschland Bundesland borders (DEU). DEFAULT: "grey80"

eu

Color of Europe country borders (EUR). DEFAULT: "black"

col

Color palette for the data itself. DEFAULT: berryFunctions::seqPal()

xlim

xlim. DEFAULT: NULL, i.e. taken from x extent (after reprojection if project=TRUE)

ylim

ylim. DEFAULT: NULL, i.e. taken from y extent (after reprojection if project=TRUE)

zlim

zlim. 3 Options: two-number vector, zlim="ind" for individual zlim per layer, or NULL for range of selected layer(s). DEFAULT: NULL

axes

Draw axes? DEFAULT: TRUE

las

LabelAxisStyle for axes. DEFAULT: 1 (all upright)

mar

Vector with plot margins. DEFAULT: c(2.5, 3.5, 2.5, 5)

keeppar

Logical: keep the margins set with par, so later points etc are added in the right location? DEFAULT: TRUE, opposite to sf::plot with reset=TRUE, see https://github.com/cran/sf/blob/master/R/plot.R

project

Project the data before plotting? Not needed if projectRasterDWD() has already been called. DEFAULT: TRUE

proj

current projection, see projectRasterDWD(), used only if project=TRUE. DEFAULT: "radolan"

extent

current extent, see projectRasterDWD(), used only if project=TRUE. DEFAULT: "radolan"

targetproj

target projection, see projectRasterDWD(), used only if project=TRUE. DEFAULT: "ll"

quiet

suppress progress messages? DEFAULT: FALSE through rdwdquiet()

Further arguments passed to raster::plot()

Value

raster object, projected (if project=TRUE). If length(layer)==1, only that selected layer is returned. output@title is set to main.

See Also

addBorders(), readDWD(), https://bookdown.org/brry/rdwd/raster-data.html

Examples

# NOT RUN {
# See homepage in the section 'See Also'
# }
# NOT RUN {
 ## Excluded from CRAN checks: requires internet connection
link <- "seasonal/air_temperature_mean/16_DJF/grids_germany_seasonal_air_temp_mean_188216.asc.gz"
rad <- dataDWD(link, base=gridbase, joinbf=TRUE, dir=tempdir())
radp <- plotRadar(rad, proj="seasonal", extent=rad@extent, main="plotRadar ex")
plotRadar(radp, ylim=c(52,54), project=FALSE) # reuses main

# plotRadar equivalent, map only country borders:
radpm <- projectRasterDWD(rad[[1]], proj="seasonal", extent=rad@extent)
raster::plot(radpm)
addBorders()

# several layers
url <- "daily/Project_TRY/pressure/PRED_199606_daymean.nc.gz"  #  5 MB
nc <- dataDWD(url, base=gridbase, joinbf=TRUE, dir=localtestdir())

ncp3 <- plotRadar(nc, main=paste(nc@title, nc@z[[1]]), layer=1:3,
                  col=terrain.colors(100), proj="nc", extent="nc")
plotRadar(ncp3, layer=3:4, project=FALSE) # still has all layers
plotRadar(ncp3, layer=4:5, project=FALSE, zlim="ind") # individual zlims per layer
plotRadar(ncp3, layer=1, project=FALSE, zlim=c(1016,1020))

ncp1 <- plotRadar(nc, layer=1, proj="nc", extent="nc") # much faster projection
# no longer has layers 2-4:
berryFunctions::is.error(plotRadar(ncp1, layer=1:4, project=FALSE), TRUE, TRUE)
# }
# NOT RUN {
# }