This function generates a graphical representation of thermal anomaly for different Local Climate Zones (LCZs). More details: https://bymaxanjos.github.io/LCZ4r/articles/Introd_local_LCZ4r.html
Usage
lcz_anomaly(
x,
data_frame = "",
var = "",
station_id = "",
...,
time.freq = "hour",
plot_type = "diverging_bar",
by = NULL,
impute = NULL,
iplot = TRUE,
isave = FALSE,
save_extension = "png",
inclusive = FALSE,
palette = "OKeeffe1",
ylab = "Air temperature anomaly",
xlab = "Stations",
title = "",
caption = "",
legend_name = "Anomaly"
)
Arguments
- x
A
SpatRaster
object containing the LCZ map. The LCZ map can be obtained using thelcz_get_map()
function.- data_frame
A data frame containing air temperature measurements and station IDs. The data frame should have a date field in hourly or higher resolution format.
- var
The name of the variable in the data frame representing air temperature.
- station_id
The name of the variable in the data frame representing station IDs.
- ...
Additional arguments for the
selectByDate
function from theopenair
package. These arguments allow for flexible selection of specific time periods (year, month, day, hour). Examples of how to use these arguments include:Year(s): Numeric value(s) specifying the year(s) to select. For example,
year = 1998:2004
selects all years between 1998 and 2004 (inclusive), whileyear = c(1998, 2004)
selects only the years 1998 and 2004.Month(s): Numeric or character value(s) specifying the months to select. Numeric examples:
month = 1:6
(January to June), or character examples:month = c("January", "December")
.Day(s): Numeric value(s) specifying the days to select. For instance,
day = 1:30
selects days from 1 to 30, orday = 15
selects only the 15th day of the month.Hour(s): Numeric value(s) specifying the hours to select. For example,
hour = 0:23
selects all hours in a day, whilehour = 9
selects only the 9th hour.Start date: A string specifying the start date in either start="DD/MM/YYYY" (e.g., "1/2/1999") or "YYYY-mm-dd" format (e.g., "1999-02-01").
End date: A string specifying the end date in either end="DD/MM/YYYY" (e.g., "1/2/1999") or "YYYY-mm-dd" format (e.g., "1999-02-01").
- time.freq
Defines the time period to average to. Default is “hour”, but includes “day”, “week”, “month” or “year”.
- plot_type
A character string indicating the type of plot to generate. Options include:
diverging_bar: A horizontal bar plot that diverges from the center (zero), with positive anomalies extending to the right and negative anomalies to the left. This plot is good for showing the extent and direction of anomalies in a compact format.
bar: A bar plot showing the magnitude of the anomaly for each station, colored by whether the anomaly is positive or negative. This plot is good for comparing anomalies across stations.
dot: A dot plot that displays both the mean temperature values and the reference values, with lines connecting them. The size or color of the dots can indicate the magnitude of the anomaly. Ideal for showing both absolute temperature values and their anomalies.
lollipop: A lollipop plot where each "stick" represents an anomaly value and the dots at the top represent the size of the anomaly. Useful for clearly showing positive and negative anomalies in a minimalist way.
- by
data frame time-serie split: “year”, “season”, “seasonyear”, “month”, “monthyear”, “weekday”, “weekend”, “site”, “daylight”, “dst” (daylight saving time).See argument type in openair package: https://bookdown.org/david_carslaw/openair/sections/intro/openair-package.html#the-type-option
- impute
Method to impute missing values (“mean”, “median”, “knn”, “bag”).
- iplot
Set to
TRUE
to return a plot. IfFALSE
, a data frame is returned.- isave
Set to
TRUE
to save all results (plot, time-series) into your directory.- save_extension
A character string indicating the file format for saving the plot. Options include: “png”, “jpg”, “jpeg”, “tif”, “pdf”, “svg”. The default is “png”.
- inclusive
Set to TRUE to a colorblind-friendly palette.
- palette
A character string specifying the color palette to use. The default is “OKeeffe1”. You can choose from palettes available in
MetBrewer
: https://github.com/BlakeRMills/MetBrewer?tab=readme-ov-file#palettes.- ylab
y-axis name.
- xlab
y-axis name. Default is “Station”
- title
y-axis name. Default is “" "”.
source data. Default can be “Source: LCZ4r, Stewart and Oke, 2012; Demuzere et al.2022."”.
- legend_name
Legend name for dot plot. Default is "Anomaly".
Value
A visual representation of the anomalies of air temperature of LCZ in ggplot
or data frame .csv format.
See also
See the documentation for lcz_get_map()
to obtain an LCZ map.