This function calculates the areas of LCZ classes in both percentage and square kilometers.
Usage
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]",
...
)
Arguments
- 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.
Value
A summary table of LCZ class areas if plot = FALSE, otherwise, the specified plot in ggplot format.
Examples
if (FALSE) { # \dontrun{
# 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)
} # }