Skip to contents

This function generates a graphical representation of time series air temperature data for different Local Climate Zones (LCZs). More details: https://bymaxanjos.github.io/LCZ4r/articles/Introd_local_LCZ4r.html

Usage

lcz_ts(
  x,
  data_frame = "",
  var = "",
  station_id = "",
  ...,
  time.freq = "hour",
  by = NULL,
  impute = NULL,
  iplot = TRUE,
  isave = FALSE,
  palette = "VanGogh2",
  ylab = "Air temperature [Degree Celsius]",
  xlab = "Time",
  title = "",
  caption = "LCZ4r"
)

Arguments

x

A SpatRaster object containing the LCZ map. The LCZ map can be obtained using the lcz_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 selectBydata from openair package. These include:

  • A start date string in the form "1/2/1999" or in format "YYYY-mm-dd", e.g., "1999-02-01".

  • A year or years to select, e.g., year = 1998:2004 to select 1998-2004 inclusive, or year = c(1998, 2004) to select 1998 and 2004.

  • A month or months to select. Can either be numeric, e.g., month = 1:6 to select January to June, or by name, e.g., month = c("January", "December").

time.freq

Defines the time period to average to. Default is “hour”, but includes “day”, “week”, “month” or “year”.

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. If FALSE, a data frame is returned.

isave

Set to TRUE to save all results (plot, time-series) into your directory.

palette

Default is "VanGogh2". Define your color palette from MetBrewer https://github.com/BlakeRMills/MetBrewer?tab=readme-ov-file#palettes.

ylab

y-axis name.

xlab

y-axis name. Default is “Time”

title

y-axis name. Default is “" "”.

caption

source data. Default can be “Source:LCZ4r,2024"”.

Value

A visual representation of the time series 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.

Examples

if (FALSE) { # \dontrun{
# Hourly air temperature values in 2019.
my_ts <- lcz_ts(lcz_map, df = lcz_data, var = "airT",
                 station_id = "station", year = 2019)

} # }