| Title: | Tools for Local Climate Zones and Urban Heat Island Analysis |
|---|---|
| Description: | LCZ4r is a comprehensive R package designed for analyzing and visualizing Local Climate Zones (LCZ) and Urban Heat Islands (UHI) at various spatial and temporal resolutions. It provides a suite of functions to work with LCZ data, perform urban climate analysis, and generate insights into temperature variations within urban areas. |
| Authors: | Max Anjos [aut, cre] (ORCID: <https://orcid.org/0000-0001-6394-1324>), Dayvid Medeiros [ctb] (ORCID: <https://orcid.org/0000-0002-5199-3909>), Francisco Castelhano [ctb] (ORCID: <https://orcid.org/0000-0002-6747-3545>), Antônio Campos Neto [ctb] (ORCID: <https://orcid.org/0009-0007-3844-3869>) |
| Maintainer: | Max Anjos <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.0 |
| Built: | 2026-10-29 10:22:18 UTC |
| Source: | https://github.com/ByMaxAnjos/LCZ4r |
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
lcz_anomaly( x, data_frame = "", var = "", station_id = "", ..., time.freq = "hour", extract.method = "simple", 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" )lcz_anomaly( x, data_frame = "", var = "", station_id = "", ..., time.freq = "hour", extract.method = "simple", 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" )
x |
A |
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
|
time.freq |
Defines the time period to average to. Default is “hour”, but includes “day”, “week”, “month” or “year”. |
extract.method |
A character string specifying the method used to assign the LCZ class to each station point. The default is
|
plot_type |
A character string indicating the type of plot to generate. Options include:
|
by |
data frame time-serie split: “year”, “season”, “seasonyear”, “month”, “monthyear”, “weekday”, “weekend”, “site”, “daylight”, “dst” (daylight saving time). Note that the Daylight option may result in both daytime and nighttime hours being represented in UTC.See NOAA https://gml.noaa.gov/grad/solcalc/ and argument type in openair package: https://openair-project.github.io/book/sections/intro/openair-package.html#the-type-option |
impute |
Method to impute missing values (“mean”, “median”, “knn”, “bag”). |
iplot |
Set to |
isave |
Set to |
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 |
ylab |
y-axis name. |
xlab |
y-axis name. Default is “Station” |
title |
y-axis name. Default is “" "”. |
caption |
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". |
A visual representation of the anomalies of air temperature of LCZ in ggplot or data frame .csv format.
Max Anjos (https://github.com/ByMaxAnjos)
See the documentation for lcz_get_map() to obtain an LCZ map.
## Not run: # Hourly air temperature values in 2019. my_res <- lcz_anomaly(lcz_map, data_frame = lcz_data, var = "airT", station_id = "station", year = 2020) ## End(Not run)## Not run: # Hourly air temperature values in 2019. my_res <- lcz_anomaly(lcz_map, data_frame = lcz_data, var = "airT", station_id = "station", year = 2020) ## End(Not run)
Generates an interpolated saptiotemporal anomaly map using LCZ as background. This function applies geostatistical interpolation techniques (e.g., kriging) to estimate anomaly values (e.g., air temperature) across the study area, integrating LCZ classifications. The function allows for flexible time period selection, like hour, daytime, nighttime and so on.
lcz_anomaly_map( x, data_frame = "", var = "", station_id = "", ..., sp.res = 100, tp.res = "hour", vg.model = "Sph", extract.method = "simple", by = NULL, impute = NULL, isave = FALSE, LCZinterp = TRUE )lcz_anomaly_map( x, data_frame = "", var = "", station_id = "", ..., sp.res = 100, tp.res = "hour", vg.model = "Sph", extract.method = "simple", by = NULL, impute = NULL, isave = FALSE, LCZinterp = TRUE )
x |
A |
data_frame |
A data frame containing air temperature measurements with station metadata. The data must include a date column in hourly or higher resolution. |
var |
Character. The variable to interpolate (e.g., |
station_id |
Character. The column name in |
... |
Additional arguments passed to
|
sp.res |
Numeric. Spatial resolution in meters (default: |
tp.res |
Character. Temporal resolution for averaging ( |
vg.model |
Character. Variogram model for kriging. Default is
|
extract.method |
Character. The method used to assign LCZ classes to stations:
|
by |
data frame time-serie split: “year”, “season”, “seasonyear”, “month”, “monthyear”, “weekday”, “weekend”, “site”, “daylight”, “dst” (daylight saving time). Note that the Daylight option may result in both daytime and nighttime hours being represented in UTC. See NOAA https://gml.noaa.gov/grad/solcalc/ and argument type in openair package: https://openair-project.github.io/book/sections/intro/openair-package.html#the-type-option |
impute |
Character. Method to impute missing values ( |
isave |
Logical. If |
LCZinterp |
Logical. If |
A spatially interpolated map in terra raster GeoTIFF format.
Max Anjos (https://github.com/ByMaxAnjos)
Anjos, M., Targino, A. C., Krecl, P., Oukawa, G. Y. & Braga, R. F. Analysis of the urban heat island under different synoptic patterns using local climate zones. Build. Environ. 185, 107268 (2020). Fenner, D., Meier, F., Bechtel, B., Otto, M. & Scherer, D. (2017). Intra and inter ‘local climate zone’ variability of air temperature as observed by crowdsourced citizen weather stations in Berlin, Germany. Meteorol. Z., 26, 525–547. http://www.gstat.org/
See lcz_anomaly() for LCZ interpolation evaluation.
## Not run: # Load sample data and LCZ map data("lcz_data") lcz_map <- lcz_get_map_generator(ID = "8576bde60bfe774e335190f2e8fdd125dd9f4299") # Plot the LCZ map lcz_plot_map(lcz_map) # Perform interpolation anomalies for 2020-01-02 at 04:00h my_interp <- lcz_anomaly_map( lcz_map, data_frame = lcz_data, var = "airT", station_id = "station", year = 2020, month = 1, day = 2, hour = 4, sp.res = 100, tp.res = "hour", vg.model = "Sph", LCZinterp = TRUE, isave = TRUE ) # Perform interpolation for an entire day (returns a raster stack of 24 hours) my_interp <- lcz_anomaly_map( lcz_map, data_frame = lcz_data, var = "airT", station_id = "station", year = 2020, month = 1, day = 2, sp.res = 100, tp.res = "hour", vg.model = "Sph", LCZinterp = TRUE, isave = TRUE ) ## End(Not run)## Not run: # Load sample data and LCZ map data("lcz_data") lcz_map <- lcz_get_map_generator(ID = "8576bde60bfe774e335190f2e8fdd125dd9f4299") # Plot the LCZ map lcz_plot_map(lcz_map) # Perform interpolation anomalies for 2020-01-02 at 04:00h my_interp <- lcz_anomaly_map( lcz_map, data_frame = lcz_data, var = "airT", station_id = "station", year = 2020, month = 1, day = 2, hour = 4, sp.res = 100, tp.res = "hour", vg.model = "Sph", LCZinterp = TRUE, isave = TRUE ) # Perform interpolation for an entire day (returns a raster stack of 24 hours) my_interp <- lcz_anomaly_map( lcz_map, data_frame = lcz_data, var = "airT", station_id = "station", year = 2020, month = 1, day = 2, sp.res = 100, tp.res = "hour", vg.model = "Sph", LCZinterp = TRUE, isave = TRUE ) ## End(Not run)
This function calculates the areas of LCZ classes in both percentage and square kilometers.
lcz_cal_area( x, plot_type = "bar", iplot = TRUE, isave = FALSE, save_extension = "png", show_legend = TRUE, inclusive = FALSE, xlab = "LCZ code", ylab = "Area [km2]", ... )lcz_cal_area( x, plot_type = "bar", iplot = TRUE, isave = FALSE, save_extension = "png", show_legend = TRUE, inclusive = FALSE, xlab = "LCZ code", ylab = "Area [km2]", ... )
x |
A raster SpatRaster layer containing LCZ classes. |
plot_type |
Type of plot to generate: "bar", "pie", or "donut". Default is "bar". |
iplot |
Logical, indicating whether to create a plot (default is TRUE). |
isave |
Logical, whether to save the plot to your directory (default is FALSE). |
save_extension |
File format for saving the plot. Options: "png", "jpg", "jpeg", "tif", "pdf", "svg" (default is "png"). |
show_legend |
Logical. If TRUE, displays the legend on the plot. If FALSE, the legend will be hidden. Default is TRUE. |
inclusive |
Logical. If TRUE, use a colorblind-friendly palette. Default is FALSE. |
xlab |
Character, label for the x-axis (default is "LCZ code"). |
ylab |
Character, label for the y-axis (default is "Area (km2)"). |
... |
Additional arguments to modify axis, legend, and plot labels, including title, subtitle, and caption. |
A summary table of LCZ class areas if plot = FALSE, otherwise, the specified plot in ggplot format.
See the documentation for lcz_get_map() to obtain an LCZ map.
## Not run: # Calculate LCZ area and visualize as bar plot lcz_cal_area(my_lcz_map, plot_type = "bar") # Visualize as pie chart lcz_cal_area(my_lcz_map, plot_type = "pie") # Save donut chart plot lcz_cal_area(my_lcz_map, plot_type = "donut", isave = TRUE) # Return a dataframe lcz_cal_area(my_lcz_map, plot_type = "donut", iplot = FALSE) ## End(Not run)## Not run: # Calculate LCZ area and visualize as bar plot lcz_cal_area(my_lcz_map, plot_type = "bar") # Visualize as pie chart lcz_cal_area(my_lcz_map, plot_type = "pie") # Save donut chart plot lcz_cal_area(my_lcz_map, plot_type = "donut", isave = TRUE) # Return a dataframe lcz_cal_area(my_lcz_map, plot_type = "donut", iplot = FALSE) ## End(Not run)
This dataset is a subset of data from the Urban Climate Observatory (UCO) in Berlin, Germany. It contains hourly air temperature readings from 23 meteorological stations for the period of 2019-2020.
lcz_datalcz_data
A data frame with 386,354 rows and 5 columns:
Date and time in POSIXct format: "2019-01-01 00:00:00"
Name of the meteorological station
Air temperature in degree celsius
Latitude of the station
Longitude of the station
data(lcz_data)data(lcz_data)
This function retrieves the Local Climate Zone (LCZ) global mapping dataset It allows you to obtain the LCZ map for a specific area of interest, which can be a city, state, region, or custom-defined shape.
lcz_get_map(city = NULL, roi = NULL, isave_map = FALSE, isave_global = FALSE)lcz_get_map(city = NULL, roi = NULL, isave_map = FALSE, isave_global = FALSE)
city |
A character string specifying the name of your target area based on the OpenStreetMap project. |
roi |
Optionally, you can provide a Region of Interest (ROI) in ESRI shapefile format to clip the LCZ map to a custom area. |
isave_map |
Logical. Set to TRUE if you wish to save the resulting clipped map as a raster TIFF file on your local machine. |
isave_global |
Logical. Set to TRUE if you wish to save the global LCZ map as a raster TIFF file on your local machine. |
A Terra raster TIFF file containing LCZ classes (1-17).
Demuzere, M., Kittner, J., Martilli, A., Mills, G., Moede, C., Stewart, I. D., van Vliet, J., and Bechtel, B. (2022). A global map of Local Climate Zones to support earth system modelling and urban scale environmental science, Earth Syst. Sci. Data 14(8) 3835-3873. DOI:https://doi.org/10.5194/essd-14-3835-2022 Zenodo. https://doi.org/10.5281/zenodo.6364594 Stewart ID, Oke TR. (2012). Local Climate Zones for Urban Temperature Studies. Bull Am Meteorol Soc. 93(12):1879-1900. doi:10.1175/BAMS-D-11-00019.1
## Not run: # Load the LCZ map for a city my_lcz_city <- lcz_get_map(city = "your city") # Get LCZ map for a custom region of interest custom_roi <- sf::st_read("custom_roi.shp") roi_lcz <- lcz_get_map(roi = custom_roi, isave_map = TRUE) # Retrieve the LCZ map for a country my_lcz_country <- lcz_get_map(city = "Brazil") ## End(Not run)## Not run: # Load the LCZ map for a city my_lcz_city <- lcz_get_map(city = "your city") # Get LCZ map for a custom region of interest custom_roi <- sf::st_read("custom_roi.shp") roi_lcz <- lcz_get_map(roi = custom_roi, isave_map = TRUE) # Retrieve the LCZ map for a country my_lcz_country <- lcz_get_map(city = "Brazil") ## End(Not run)
This function retrieves the Local Climate Zone (LCZ) European mapping dataset created by Demuzere et al. (2019) and available at https://doi.org/10.1371/journal.pone.0214474. It allows you to obtain the LCZ map for a specific area of interest, which can be a city, state, region, or custom-defined shape.
lcz_get_map_euro( city = NULL, roi = NULL, isave_map = FALSE, isave_euro = FALSE )lcz_get_map_euro( city = NULL, roi = NULL, isave_map = FALSE, isave_euro = FALSE )
city |
A character string specifying the name of your target area based on the OpenStreetMap project. |
roi |
Optionally, you can provide a Region of Interest (ROI) in ESRI shapefile format to clip the LCZ map to a custom area. |
isave_map |
Logical. Set to TRUE if you wish to save the resulting clipped map as a raster TIFF file on your local machine. |
isave_euro |
Logical. Set to TRUE if you wish to save the European LCZ map as a raster TIFF file on your local machine. |
A Terra raster TIFF file containing LCZ classes (1-17).
Demuzere, M., Bechtel, B., Middel, A., & Mills, G. (2019). Mapping Europe into local climate zones. PLOS ONE, 14(4), e0214474. DOI:https://doi.org/10.1371/journal.pone.0214474 Demuzere, M.; Bechtel, B.; Middel, A.; Mills, G. (2019): European LCZ map. Figshare. Dataset. https://doi.org/10.6084/m9.figshare.13322450 Anjos, M. (2024). LCZ4r Package Dataset. Zenodo. https://doi.org/10.5281/zenodo.10835692
## Not run: # Example 1: Load the LCZ map for a city my_lcz_city <- lcz_get_map_euro(city = "Berlin") # Example 2: Get LCZ map for a custom region of interest custom_roi <- sf::st_read("custom_roi.shp") roi_lcz <- lcz_get_map_euro(roi = custom_roi) ## End(Not run)## Not run: # Example 1: Load the LCZ map for a city my_lcz_city <- lcz_get_map_euro(city = "Berlin") # Example 2: Get LCZ map for a custom region of interest custom_roi <- sf::st_read("custom_roi.shp") roi_lcz <- lcz_get_map_euro(roi = custom_roi) ## End(Not run)
This function retrieves the LCZ map from LCZ Generator platform
lcz_get_map_generator( ID = "3110e623fbe4e73b1cde55f0e9832c4f5640ac21", band = "lczFilter", isave_map = FALSE )lcz_get_map_generator( ID = "3110e623fbe4e73b1cde55f0e9832c4f5640ac21", band = "lczFilter", isave_map = FALSE )
ID |
A code specifying the ID generated by LCZ Factsheet (e.g, "3110e623fbe4e73b1cde55f0e9832c4f5640ac21"). More details: https://lcz-generator.rub.de/factsheets/3110e623fbe4e73b1cde55f0e9832c4f5640ac21/3110e623fbe4e73b1cde55f0e9832c4f5640ac21_factsheet.html |
band |
Select the feature to use. The available options are: “lcz” and “lczFilter”. The default is "lczFilter". |
isave_map |
Logical. Set to TRUE if you wish to save the resulting map as a raster TIFF file on your local machine. |
A Terra raster TIFF file containing LCZ classes (1-17).
Demuzere, M., Kittner, J., Bechtel, B. (2021). LCZ Generator: a web application to create Local Climate Zone maps. Frontiers in Environmental Science 9:637455. https://doi.org/10.3389/fenvs.2021.637455
## Not run: # Load the Rio de Janeiro map from LCZ Generator my_lcz_map <- lcz_get_map_generator(ID = "3110e623fbe4e73b1cde55f0e9832c4f5640ac21") ## End(Not run)## Not run: # Load the Rio de Janeiro map from LCZ Generator my_lcz_map <- lcz_get_map_generator(ID = "3110e623fbe4e73b1cde55f0e9832c4f5640ac21") ## End(Not run)
This function retrieves the Local Climate Zone (LCZ) CONUS LCZ mapping dataset created by Demuzere et al. (2020) and available at https://doi.org/10.1038/s41597-020-00605-z. It allows you to obtain the LCZ map for a specific area of interest, which can be a city, state, region, or custom-defined shape.
lcz_get_map_usa(city = NULL, roi = NULL, isave_map = FALSE, isave_usa = FALSE)lcz_get_map_usa(city = NULL, roi = NULL, isave_map = FALSE, isave_usa = FALSE)
city |
A character string specifying the name of your target area based on the OpenStreetMap project. |
roi |
Optionally, you can provide a Region of Interest (ROI) in ESRI shapefile format to clip the LCZ map to a custom area. |
isave_map |
Logical. Set to TRUE if you wish to save the resulting clipped map as a raster TIFF file on your local machine. |
isave_usa |
Logical. Set to TRUE if you wish to save the USA LCZ map as a raster TIFF file on your local machine. |
A Terra raster TIFF file containing LCZ classes (1-17).
Demuzere, M., Hankey, S., Mills, G., Zhang, W., Lu, T., & Bechtel, B. (2020). Combining expert and crowd-sourced training data to map urban form and functions for the continental US. Scientific Data, 7(1), 264. DOI:https://doi.org/10.1038/s41597-020-00605-z Demuzere, M., Hankey, S., Mills, G., Zhang, W., Lu, T., Bechtel B. (2020): CONUS-wide LCZ map and Training Areas. Figshare. Dataset. https://doi.org/10.6084/m9.figshare.11416950 Anjos, M. (2024). LCZ4r Package Dataset. Zenodo. https://doi.org/10.5281/zenodo.10835692
## Not run: # Example 1: Load the LCZ map for a city my_lcz_city <- lcz_get_map_usa(city = "New York") # Example 2: Get LCZ map for a custom region of interest custom_roi <- sf::st_read("custom_roi.shp") roi_lcz <- lcz_get_map_usa(roi = custom_roi) ## End(Not run)## Not run: # Example 1: Load the LCZ map for a city my_lcz_city <- lcz_get_map_usa(city = "New York") # Example 2: Get LCZ map for a custom region of interest custom_roi <- sf::st_read("custom_roi.shp") roi_lcz <- lcz_get_map_usa(roi = custom_roi) ## End(Not run)
This function retrieves the Local Climate Zone (LCZ) global mapping dataset created by Demuzere et al. (2022) and available at https://doi.org/10.5194/essd-14-3835-2022. It allows you to obtain the LCZ map for a specific area of interest, which can be a city, state, region, or custom-defined shape.
lcz_get_map2(x, city = NULL, roi = NULL, isave_map = FALSE)lcz_get_map2(x, city = NULL, roi = NULL, isave_map = FALSE)
x |
A SpatRaster object containing the LCZ map. It can be download using these links: https://lcz-generator.rub.de/ , https://zenodo.org/records/8419340/files/lcz_filter_v3.tif?download=1". Then, it suggested use terra::rast(path/name.tif") to import the raster .tif into R. |
city |
A character string specifying the name of your target area based on the OpenStreetMap project. |
roi |
Optionally, you can provide a Region of Interest (ROI) in ESRI shapefile format to clip the LCZ map to a custom area. |
isave_map |
Logical. Set to TRUE if you wish to save the resulting clipped map as a raster TIFF file on your local machine. |
A Terra raster TIFF file containing LCZ classes for the specified area of interest.
## Not run: # Go to https://lcz-generator.rub.de/ my_map <- terra::rast("path/name.tif") my_lcz_map <- lcz_get_map2(my_map, city = "Name") # Load the LCZ map from your PC my_map <- terra::rast("path/lcz_filter_v3.tif") # Get LCZ map for a custom region of interest custom_roi <- sf::st_read("custom_roi.shp") roi_lcz <- lcz_get_map2(my_map, roi = custom_roi) # Retrieve the LCZ map for a country (no custom ROI specified) my_lcz_country <- lcz_get_map2(my_map, city = "Lisbon") ## End(Not run)## Not run: # Go to https://lcz-generator.rub.de/ my_map <- terra::rast("path/name.tif") my_lcz_map <- lcz_get_map2(my_map, city = "Name") # Load the LCZ map from your PC my_map <- terra::rast("path/lcz_filter_v3.tif") # Get LCZ map for a custom region of interest custom_roi <- sf::st_read("custom_roi.shp") roi_lcz <- lcz_get_map2(my_map, roi = custom_roi) # Retrieve the LCZ map for a country (no custom ROI specified) my_lcz_country <- lcz_get_map2(my_map, city = "Lisbon") ## End(Not run)
This function extracts 34 LCZ parameters based on the classification scheme developed by Stewart and Oke (2012). LCZs provide valuable information about urban morphology and are useful for urban climate and environmental studies.
lcz_get_parameters(x, iselect = "", istack = TRUE, ishp = FALSE, isave = FALSE)lcz_get_parameters(x, iselect = "", istack = TRUE, ishp = FALSE, isave = FALSE)
x |
A LCZ map in .tiff format SpatRaster object containing LCZ classes. |
iselect |
Code vector. Specify one or more parameter:
|
istack |
Logical. If TRUE, returns all parameters as a raster stack. If FALSE, returns a list of individual parameter rasters. |
ishp |
Logical. If TRUE, returns all parameters as an ESRI shapefile. |
isave |
Set to TRUE if you want to save the your clipped resulting map as a raster.tiff or .shp file on your local machine. |
If 'istack' is TRUE, it returns a raster stack containing 34 LCZ-related parameters. If 'istack' is FALSE, it returns a list of individual parameter rasters. If 'ishp' is TRUE, it returns an ESRI shapefile containing all parameters. If 'iselect' is specified, it returns the selected parameter(s) as a raster(s).
Max Anjos (https://github.com/ByMaxAnjos)
Stewart, I., and T. Oke, 2012: Local climate zones for urban temperature studies. Bull. Amer. Meteor. Soc., 93, 1879–1900. https://doi.org/10.1175/BAMS-D-11-00019.1
## Not run: # Load the LCZ map lcz_map <- raster::raster("path/to/lcz_map.tif") # Get LCZ parameters as a raster stack lcz_params_stack <- lcz_get_parameters(lcz_map, istack = TRUE) # Get LCZ parameters as a list of individual parameter rasters lcz_params_list <- lcz_get_parameters(lcz_map, istack = FALSE) # Access individual parameters from the list specific_param <- lcz_params_list$parameter_name # Get specific parameters as a raster or shapefile selected_params <- lcz_get_parameters(lcz_map, iselect = c("SVFmin")) ## End(Not run)## Not run: # Load the LCZ map lcz_map <- raster::raster("path/to/lcz_map.tif") # Get LCZ parameters as a raster stack lcz_params_stack <- lcz_get_parameters(lcz_map, istack = TRUE) # Get LCZ parameters as a list of individual parameter rasters lcz_params_list <- lcz_get_parameters(lcz_map, istack = FALSE) # Access individual parameters from the list specific_param <- lcz_params_list$parameter_name # Get specific parameters as a raster or shapefile selected_params <- lcz_get_parameters(lcz_map, iselect = c("SVFmin")) ## End(Not run)
This function evaluates the variability of a spatial and temporal interpolation of a variable (e.g., air temperature) using LCZ as background. It supports both LCZ-based and conventional interpolation methods. The function allows for flexible time period selection, cross-validation, and station splitting for training and testing.
lcz_interp_eval( x, data_frame = "", var = "", station_id = "", ..., extract.method = "simple", LOOCV = TRUE, split.ratio = 0.8, sp.res = 100, tp.res = "hour", vg.model = "Sph", by = NULL, Anomaly = FALSE, impute = NULL, isave = FALSE, LCZinterp = TRUE )lcz_interp_eval( x, data_frame = "", var = "", station_id = "", ..., extract.method = "simple", LOOCV = TRUE, split.ratio = 0.8, sp.res = 100, tp.res = "hour", vg.model = "Sph", by = NULL, Anomaly = FALSE, impute = NULL, isave = FALSE, LCZinterp = TRUE )
x |
A |
data_frame |
A data frame containing air temperature measurements and station IDs. The data frame must include a date field in hourly or higher resolution format. |
var |
A character string specifying the name of the variable to interpolate (e.g., "airT" for air temperature). |
station_id |
A character string specifying the name of the station ID variable in the data frame. |
... |
Additional arguments for the
|
extract.method |
A character string specifying the method used to assign the LCZ class to each station point. The default is
|
LOOCV |
A logical value. If |
split.ratio |
A numeric value representing the proportion of meteorological stations to be used for training (interpolation). The remaining stations will be used for testing (evaluation). For example, the default |
sp.res |
A numeric value specifying the spatial resolution in meters for interpolation. The default is |
tp.res |
A character string specifying the temporal resolution for averaging. The default is |
vg.model |
A character string specifying the variogram model for kriging. The default is
|
by |
data frame time-serie split: “year”, “season”, “seasonyear”, “month”, “monthyear”, “weekday”, “weekend”, “site”, “daylight”, “dst” (daylight saving time). Note that the Daylight option may result in both daytime and nighttime hours being represented in UTC. See NOAA https://gml.noaa.gov/grad/solcalc/ and argument type in openair package: https://openair-project.github.io/book/sections/intro/openair-package.html#the-type-option |
Anomaly |
If |
impute |
A character string specifying the method to impute missing values. Options include |
isave |
A logical value. If |
LCZinterp |
A logical value. If |
A summary table in CSV format containing time series of observed values, predicted values, and residuals. It also returns an ESRI shapefile (.gpkg) containing metadata of the interpolation.
Max Anjos (https://github.com/ByMaxAnjos)
Anjos, M., Targino, A. C., Krecl, P., Oukawa, G. Y. & Braga, R. F. Analysis of the urban heat island under different synoptic patterns using local climate zones. Build. Environ. 185, 107268 (2020). Fenner, D., Meier, F., Bechtel, B., Otto, M. & Scherer, D. Intra and inter ‘local climate zone’ variability of air temperature as observed by crowdsourced citizen weather stations in Berlin, Germany. Meteorol. Z. 26, 525–547 (2017). http://www.gstat.org/
## Not run: # Evaluate air temperature interpolation values using Berlin data and LOOCV data("lcz_data") lcz_map <- lcz_get_map_generator(ID = "8576bde60bfe774e335190f2e8fdd125dd9f4299") lcz_plot_map(lcz_map) my_interp <- lcz_interp_eval( lcz_map, data_frame = lcz_data, var = "airT", station_id = "station", year = 2019, month = 9, day = 5, sp.res = 100, tp.res = "hour", LOOCV = TRUE, vg.model = "Sph", LCZinterp = TRUE, isave = TRUE ) # Evaluate LCZ-based interpolation using split station (80% training, 20% testing) my_interp <- lcz_interp_eval( lcz_map, data_frame = lcz_data, var = "airT", station_id = "station", tp.res = "hour", sp.res = 100, year = 2019, month = 9, day = 5, LOOCV = FALSE, split.ratio = 0.8, vg.model = "Sph", LCZinterp = TRUE, isave = TRUE ) ## End(Not run)## Not run: # Evaluate air temperature interpolation values using Berlin data and LOOCV data("lcz_data") lcz_map <- lcz_get_map_generator(ID = "8576bde60bfe774e335190f2e8fdd125dd9f4299") lcz_plot_map(lcz_map) my_interp <- lcz_interp_eval( lcz_map, data_frame = lcz_data, var = "airT", station_id = "station", year = 2019, month = 9, day = 5, sp.res = 100, tp.res = "hour", LOOCV = TRUE, vg.model = "Sph", LCZinterp = TRUE, isave = TRUE ) # Evaluate LCZ-based interpolation using split station (80% training, 20% testing) my_interp <- lcz_interp_eval( lcz_map, data_frame = lcz_data, var = "airT", station_id = "station", tp.res = "hour", sp.res = 100, year = 2019, month = 9, day = 5, LOOCV = FALSE, split.ratio = 0.8, vg.model = "Sph", LCZinterp = TRUE, isave = TRUE ) ## End(Not run)
Generates an interpolated spatial map using LCZ as background. This function applies geostatistical interpolation techniques (e.g., kriging) to estimate variable values (e.g., air temperature) across the study area, integrating LCZ classifications. The function allows for flexible time period selection, like hour, daytime, nighttime and so on.
lcz_interp_map( x, data_frame = "", var = "", station_id = "", ..., extract.method = "simple", sp.res = 100, tp.res = "hour", vg.model = "Sph", by = NULL, impute = NULL, isave = FALSE, LCZinterp = TRUE )lcz_interp_map( x, data_frame = "", var = "", station_id = "", ..., extract.method = "simple", sp.res = 100, tp.res = "hour", vg.model = "Sph", by = NULL, impute = NULL, isave = FALSE, LCZinterp = TRUE )
x |
A |
data_frame |
A data frame containing air temperature measurements with station metadata. The data must include a date column in hourly or higher resolution. |
var |
Character. The variable to interpolate (e.g., |
station_id |
Character. The column name in |
... |
Additional arguments passed to
|
extract.method |
Character. The method used to assign LCZ classes to stations:
|
sp.res |
Numeric. Spatial resolution in meters (default: |
tp.res |
Character. Temporal resolution for averaging ( |
vg.model |
Character. Variogram model for kriging. Default is
|
by |
data frame time-serie split: “year”, “season”, “seasonyear”, “month”, “monthyear”, “weekday”, “weekend”, “site”, “daylight”, “dst” (daylight saving time). Note that the Daylight option may result in both daytime and nighttime hours being represented in UTC. See NOAA https://gml.noaa.gov/grad/solcalc/ and argument type in openair package: https://openair-project.github.io/book/sections/intro/openair-package.html#the-type-option |
impute |
Character. Method to impute missing values ( |
isave |
Logical. If |
LCZinterp |
Logical. If |
A spatially interpolated map in terra raster GeoTIFF format.
Max Anjos (https://github.com/ByMaxAnjos)
Anjos, M., Targino, A. C., Krecl, P., Oukawa, G. Y. & Braga, R. F. Analysis of the urban heat island under different synoptic patterns using local climate zones. Build. Environ. 185, 107268 (2020). Fenner, D., Meier, F., Bechtel, B., Otto, M. & Scherer, D. (2017). Intra and inter ‘local climate zone’ variability of air temperature as observed by crowdsourced citizen weather stations in Berlin, Germany. Meteorol. Z., 26, 525–547. http://www.gstat.org/
See lcz_inter_eval() for LCZ interpolation evaluation.
## Not run: # Load sample data and LCZ map data("lcz_data") lcz_map <- lcz_get_map_generator(ID = "8576bde60bfe774e335190f2e8fdd125dd9f4299") # Plot the LCZ map lcz_plot_map(lcz_map) # Perform interpolation for 2020-01-02 at 04:00h my_interp <- lcz_interp_map( lcz_map, data_frame = lcz_data, var = "airT", station_id = "station", year = 2020, month = 1, day = 2, hour = 4, sp.res = 100, tp.res = "hour", vg.model = "Sph", LCZinterp = TRUE ) # Perform interpolation for an entire day (returns a raster stack of 24 hours) my_interp <- lcz_interp_map( lcz_map, data_frame = lcz_data, var = "airT", station_id = "station", year = 2020, month = 1, day = 2, sp.res = 100, tp.res = "hour", vg.model = "Sph", LCZinterp = TRUE ) ## End(Not run)## Not run: # Load sample data and LCZ map data("lcz_data") lcz_map <- lcz_get_map_generator(ID = "8576bde60bfe774e335190f2e8fdd125dd9f4299") # Plot the LCZ map lcz_plot_map(lcz_map) # Perform interpolation for 2020-01-02 at 04:00h my_interp <- lcz_interp_map( lcz_map, data_frame = lcz_data, var = "airT", station_id = "station", year = 2020, month = 1, day = 2, hour = 4, sp.res = 100, tp.res = "hour", vg.model = "Sph", LCZinterp = TRUE ) # Perform interpolation for an entire day (returns a raster stack of 24 hours) my_interp <- lcz_interp_map( lcz_map, data_frame = lcz_data, var = "airT", station_id = "station", year = 2020, month = 1, day = 2, sp.res = 100, tp.res = "hour", vg.model = "Sph", LCZinterp = TRUE ) ## End(Not run)
This function plots the interpolated LCZ anomaly, LCZ air temperature, or other environmental variables.
lcz_plot_interp( x, palette = "muted", direction = 1, isave = FALSE, save_extension = "png", ... )lcz_plot_interp( x, palette = "muted", direction = 1, isave = FALSE, save_extension = "png", ... )
x |
The LCZ map in SpatRaster format, either as a single raster or a raster stack, obtained from functions like lcz_anomaly_map() or lcz_interp_map(). |
palette |
Gradient palettes available in the tidyterra package. Default is "muted". More palettes can be found in the tidyterra documentation: https://dieghernan.github.io/tidyterra/articles/palettes.html#scale_fill_whitebox_ |
direction |
Sets order of colors. Default palette is 1. If direction is -1, palette color order is reversed |
isave |
Logical, indicating whether to save the plot to your directory. Default is FALSE. |
save_extension |
File format for saving the plot. Options: "png", "jpg", "jpeg", "tif", "pdf", "svg" (default is "png"). |
... |
Additional arguments to modify axis, legend, and plot labels, including title, subtitle, and caption. |
A plot of the LCZ interpolated map in ggplot2 format.
See the documentation for lcz_anomaly_map() to obtain LCZ anomaly rasters and lcz_interp_map() for air temperature rasters.
## Not run: # Plot the interpolated map lcz_plot_interp(my_interp_map) ## End(Not run)## Not run: # Plot the interpolated map lcz_plot_interp(my_interp_map) ## End(Not run)
This function generates a graphical representation of a Local Climate Zone (LCZ) map provided as a SpatRaster object.
lcz_plot_map( x, isave = FALSE, show_legend = TRUE, save_extension = "png", inclusive = FALSE, ... )lcz_plot_map( x, isave = FALSE, show_legend = TRUE, save_extension = "png", inclusive = FALSE, ... )
x |
A SpatRaster object containing the LCZ map to be plotted. |
isave |
Logical. Set to TRUE to save the plot in your working directory. |
show_legend |
Logical. If TRUE, displays the legend on the plot. If FALSE, the legend will be hidden. Default is TRUE. |
save_extension |
File format for saving the plot. Options: "png", "jpg", "jpeg", "tif", "pdf", "svg" (default is "png"). |
inclusive |
Logical. Set to TRUE to use a colorblind-friendly palette. |
... |
Optional arguments to modify axis labels, legend, plot title, subtitle, and caption. |
A visual representation of the LCZ map in ggplot format.
See the documentation for lcz_get_map() to obtain an LCZ map.
## Not run: lcz_plot_map(LCZmap) ## End(Not run)## Not run: lcz_plot_map(LCZmap) ## End(Not run)
This function plots the parameters of an Local Climate Zone map.
lcz_plot_parameters( x, iselect = "", all = FALSE, inclusive = FALSE, isave = FALSE, save_extension = "png", ... )lcz_plot_parameters( x, iselect = "", all = FALSE, inclusive = FALSE, isave = FALSE, save_extension = "png", ... )
x |
The LCZ map in SpatRaster in a stack format. |
iselect |
Code vector. Specify one or more parameter:
|
all |
Logical, specifying whether to save all selected parameters into LCZ4r_output. Default is FALSE. |
inclusive |
Set to TRUE to a colorblind-friendly palette. |
isave |
Logical, indicating whether to save the plot to your directory. Default is FALSE. |
save_extension |
File format for saving the plot. Options: "png", "jpg", "jpeg", "tif", "pdf", "svg" (default is "png"). |
... |
An optional modify axis, legend, and plot labels: subtitle, and caption. It does not work with title. |
A plot of the selected LCZ parameters in ggplot2 format
#'@references Stewart, I., and T. Oke, 2012: Local climate zones for urban temperature studies. Bull. Amer. Meteor. Soc., 93, 1879–1900. https://doi.org/10.1175/BAMS-D-11-00019.1
See the documentation for lcz_get_parameters() to obtain LCZ parameters.
## Not run: # Plot the mean Sky View Factor (SVFmean) for your city lcz_plot_parameters(lcz_map, iselect = "SVFmean") # Plot multiple parameters and save them to the LCZ4r_output directory lcz_plot_parameters(lcz_map, iselect = c("BSFmean", "AHmean")) ## End(Not run)## Not run: # Plot the mean Sky View Factor (SVFmean) for your city lcz_plot_parameters(lcz_map, iselect = "SVFmean") # Plot multiple parameters and save them to the LCZ4r_output directory lcz_plot_parameters(lcz_map, iselect = c("BSFmean", "AHmean")) ## End(Not run)
This function generates a graphical representation of time series air temperature data across different Local Climate Zones (LCZs). It allows for flexible temporal aggregation, faceting, smoothing, and visualization options including heatmaps, facet_plot line plots, and warming stripes. For more details on LCZ analysis, visit https://bymaxanjos.github.io/LCZ4r/articles/Introd_local_LCZ4r.html.
lcz_ts( x, data_frame = "", var = "", station_id = "", ..., time.freq = "hour", extract.method = "simple", plot_type = "basic_line", facet_plot = "LCZ", by = NULL, smooth = FALSE, impute = NULL, iplot = TRUE, isave = FALSE, save_extension = "png", palette = "VanGogh2", ylab = "Air temperature [Degree Celsius]", xlab = "Time", title = "LCZ - Timeseries", caption = "LCZ4r, 2024.", legend_name = "Temperature (C)" )lcz_ts( x, data_frame = "", var = "", station_id = "", ..., time.freq = "hour", extract.method = "simple", plot_type = "basic_line", facet_plot = "LCZ", by = NULL, smooth = FALSE, impute = NULL, iplot = TRUE, isave = FALSE, save_extension = "png", palette = "VanGogh2", ylab = "Air temperature [Degree Celsius]", xlab = "Time", title = "LCZ - Timeseries", caption = "LCZ4r, 2024.", legend_name = "Temperature (C)" )
x |
A |
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
|
time.freq |
Defines the time period to average to. Default is “hour”, but includes “day”, “week”, “month” or “year”. |
extract.method |
A character string specifying the method used to assign the LCZ class to each station point. The default is
|
plot_type |
A character string indicating the type of plot to generate. Options include: “basic_line”, “facet_line”, “heatmap”, “warming_stripes”. The default is “basic_line”. Note: This argument does not work if the |
facet_plot |
A character string indicating whether to divide the plot by “LCZ” or “station”. The default is “LCZ”. |
by |
data frame time-serie split: “year”, “season”, “seasonyear”, “month”, “monthyear”, “weekday”, “weekend”, “site”, “daylight”, “dst” (daylight saving time). Note that the Daylight option may result in both daytime and nighttime hours being represented in UTC. See NOAA https://gml.noaa.gov/grad/solcalc/ and argument type in openair package: https://openair-project.github.io/book/sections/intro/openair-package.html#the-type-option |
smooth |
Logical. Set to |
impute |
Method to impute missing values (“mean”, “median”, “knn”, “bag”). |
iplot |
Set to |
isave |
Set to |
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”. |
palette |
A character string specifying the color palette to use. The default is “VanGogh2”. You can choose from palettes available in |
ylab |
A character string for the y-axis label. The default is the variable name. |
xlab |
A character string for the x-axis label. The default is “Time”. |
title |
A character string for the plot title. The default is “""”. |
caption |
source data. Default can be “Source:LCZ4r,2024"”. |
legend_name |
Legend name for heatmap and warming stripes plots. Default is "Temperature (°C)". |
A ggplot object representing the time series of air temperature in different LCZs, or a data frame in CSV format if iplot = FALSE.
Max Anjos (https://github.com/ByMaxAnjos)
See the documentation for lcz_get_map(), lcz_get_map_euro(), and lcz_get_map_usa() to obtain an LCZ map.
## Not run: # Hourly air temperature values in 2019. my_ts <- lcz_ts(lcz_map, df = lcz_data, var = "airT", station_id = "station", year = 2020) ## End(Not run)## Not run: # Hourly air temperature values in 2019. my_ts <- lcz_ts(lcz_map, df = lcz_data, var = "airT", station_id = "station", year = 2020) ## End(Not run)
Opens LCZ4r tutorial in a web browser. This function requires an internet connection.
lcz_tutorial(x = "general")lcz_tutorial(x = "general")
x |
Character string. Either "general" for general functions or "local" for local functions. Default is "general". |
Opens the LCZ4r tutorial in a web browser.
## Not run: lcz_tutorial("general") lcz_tutorial("local") ## End(Not run)## Not run: lcz_tutorial("general") lcz_tutorial("local") ## End(Not run)
This function calculates the Urban Heat Island (UHI) intensity based on air temperature measurements and Local Climate Zones (LCZ). More details: https://bymaxanjos.github.io/LCZ4r/articles/Introd_local_LCZ4r.html
lcz_uhi_intensity( x, data_frame = "", var = "", station_id = "", ..., time.freq = "hour", extract.method = "simple", method = "LCZ", Turban = NULL, Trural = NULL, by = NULL, impute = NULL, group = FALSE, iplot = TRUE, isave = FALSE, save_extension = "png", ylab = "Air temperature [C]", xlab = "Time", ylab2 = "UHI", title = "", caption = "LCZ4r,2024" )lcz_uhi_intensity( x, data_frame = "", var = "", station_id = "", ..., time.freq = "hour", extract.method = "simple", method = "LCZ", Turban = NULL, Trural = NULL, by = NULL, impute = NULL, group = FALSE, iplot = TRUE, isave = FALSE, save_extension = "png", ylab = "Air temperature [C]", xlab = "Time", ylab2 = "UHI", title = "", caption = "LCZ4r,2024" )
x |
A |
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
|
time.freq |
The time period to average to. Default is “hour”, but can also be “day”, “week”, “month”, or “year”. |
extract.method |
A character string specifying the method used to assign the LCZ class to each station point. The default is
|
method |
Method to calculate the UHI intensity. Options include: LCZ and manual. The LCZ method automatically identifies the LCZ build types, starting from LCZ 1 and progressing to LCZ 10, to represent the urban temperature, then it starts from LCZ natural LCZ (11-16) to represent the rural temperature. The manual method is a character string indicating the stations as references for the urban and rural areas. |
Turban |
Urban station references, if the method "manual" is selected. |
Trural |
Rural station references, if the method "manual" is selected. |
by |
data frame time-serie split: “year”, “season”, “seasonyear”, “month”, “monthyear”, “weekday”, “weekend”, “site”, “daylight”, “dst” (daylight saving time). Note that the Daylight option may result in both daytime and nighttime hours being represented in UTC. See NOAA https://gml.noaa.gov/grad/solcalc/ and argument type in openair package: https://openair-project.github.io/book/sections/intro/openair-package.html#the-type-option |
impute |
Method to impute missing values. Options include “mean”, “median”, “knn”, or “bag”. |
group |
If TRUE urban, rural and UHI - related temperatures are grouped in the same plot. |
iplot |
Set to |
isave |
Set to |
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”. |
ylab |
The label for the y-axis. |
xlab |
The label for the x-axis. Default is “Time”. |
ylab2 |
The label for the right y-axis. |
title |
The title of the plot. Default is an empty string. |
caption |
The source data caption. |
A visual representation of the time series of UHI in ggplot or data frame .csv format.
Max Anjos (https://github.com/ByMaxAnjos)
See the documentation for lcz_get_map() to obtain an LCZ map.
## Not run: # Calculate hourly UHI intensity for 2019 using the LCZ method my_uhi <- lcz_uhi_intensity(lcz_map, data_frame = lcz_data, var = "airT", station_id = "station", year = 2019, time.freq = "hour", method = "LCZ") ## End(Not run)## Not run: # Calculate hourly UHI intensity for 2019 using the LCZ method my_uhi <- lcz_uhi_intensity(lcz_map, data_frame = lcz_data, var = "airT", station_id = "station", year = 2019, time.freq = "hour", method = "LCZ") ## End(Not run)