plotRadar: plot radar products on a pretty map

View source: R/plotRadar.R

plotRadarR Documentation

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 = names(x),
  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",
  adjust05 = FALSE,
  targetproj = "ll",
  quiet = rdwdquiet(),
  ...
)

Arguments

x

terra 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. DEFAULT: names(x)

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. DEFAULT: "grey80"

eu

Color of Europe country borders . 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"

adjust05

Logical: Adjust extent by 0.5m to match edges? DEFAULT: FALSE

targetproj

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

quiet

suppress progress messages? DEFAULT: FALSE through rdwdquiet()

...

Further arguments passed to terra::plot()

Value

terra object, (re)projected (if project=TRUE). If length(layer)==1, only that selected layer is returned.

Author(s)

Berry Boessenkool, berry-b@gmx.de, Feb 2020, June 2023

See Also

projectRasterDWD(), addBorders(), readDWD(), website raster chapter

Examples

# See https://bookdown.org/brry/rdwd/raster-data.html
## 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)
radp <- plotRadar(rad, proj="seasonal", extent=NULL, main="plotRadar ex")
plotRadar(radp, ylim=c(52,54), project=FALSE)

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

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

ncp3 <- plotRadar(nc, main=paste(terra::longnames(nc), terra::time(nc)), 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)

## End(Not run)


brry/rdwd documentation built on April 18, 2024, 4:16 a.m.