qsm2shade
is an R package to calculate the shadow casting of QSMs (quantitative structure models) created in Matlab using TreeQSM. The package uses QSM
objects read in using qsm2r. The shade of the tree for one sun position can be plotted using plot_shade_wood()
. To enable shade estimation of trees carrying leaves or flowers, those can be simulated using add_items()
. To plot added items and their shade, use plot_items()
and plot_shade_items()
. To simulate the shading of a tree with or without added items over time, the function shade_tree()
can be used. To increase efficiency, the simulation of the shade can be executed using parallel processing. The used time steps should be one hour or less, the radiation data should be given in hourly steps and the energy unit should correspond to the chosen time steps and raster resolution.
Zoe Schindler, Chair of Forest Growth and Dendroecology, University of Freiburg
Schindler Z, Larysch E, Frey J, Sheppard JP, Obladen N, Kröner K, Seifert T, Morhart C (2024). From dawn to dusk: High resolution tree shading model based on terrestrial LiDAR data. Remote Sensing 16(12), 2189. doi: 10.3390/rs16122189
Rosskopf E, Morhart C, Nahm M (2017). Modelling Shadow Using 3D Tree Models in High Spatial and Temporal Resolution. Remote Sensing 9(7), 719. doi: 10.3390/rs9070719
To install the package from github, the package remotes
is required.
# install package from github
remotes::install_github("zoeschindler/qsm2shade")
# load qsm
file_path <- system.file("extdata", "Prunus_avium_QSM_simplified.mat", package="qsm2shade")
qsm <- qsm2r::readQSM(file_path)
# shift qsm to origin
# (shade is always projected to z = 0)
qsm <- qsm2r::set_location(qsm, c(0,0,0))
# plot qsm
qsm2r::plot(qsm, col = "salmon4", lit = TRUE)
# plot shade of wood
plot_shade_wood(qsm)
# load qsm
file_path <- system.file("extdata", "Prunus_avium_QSM_simplified.mat", package="qsm2shade")
qsm <- qsm2r::readQSM(file_path)
# shift qsm to origin
# (shade is always projected to z = 0)
qsm <- qsm2r::set_location(qsm, c(0,0,0))
# create dummy item regression
distribution <- dummy_item_distribution()
# create polygons for single item
leaf <- create_single_leaf(leaf_type = "normal", length_m = 0.1)
# add items
leaves <- add_items(qsm, distribution, leaf, item_type = "leaves")
# plot qsm
qsm2r::plot(qsm, col = "salmon4", lit = TRUE)
# plot items
plot_items(leaves, col = "darkolivegreen3")
# plot shade of wood
plot_shade_wood(qsm)
# plot shade of items
plot_shade_items(leaves)
# load qsm
file_path <- system.file("extdata", "Prunus_avium_QSM_simplified.mat", package="qsm2shade")
qsm <- qsm2r::readQSM(file_path)
# shift qsm to origin
# (shade is always projected to z = 0)
qsm <- qsm2r::set_location(qsm, c(0,0,0))
# get sun position at different times (one day, 10 min steps)
timeframe <- seq(ISOdate(2020, 03, 22, 0, 0), ISOdate(2020, 03, 22, 23, 50), "10 mins")
sun_position <- sun_movement(timeframe, latitude = 48.07, longitude = 7.60)
# create dummy radiation data
radiation <- dummy_radiation(ISOdate(2020, 01, 01, 0, 0), ISOdate(2020, 12, 31, 23, 50), "1 hour")
# calculate shade (10cm resolution)
result <- shade_tree(qsm, sun_position, radiation, resolution = 0.1)
# show shade
terra::plot(result)
# load qsm
file_path <- system.file("extdata", "Prunus_avium_QSM_simplified.mat", package="qsm2shade")
qsm <- qsm2r::readQSM(file_path)
# shift qsm to origin
# (shade is always projected to z = 0)
qsm <- qsm2r::set_location(qsm, c(0,0,0))
# dummy sun direction
sun_dir <- c(0.25, -0.5, -0.75)
# plot qsm
qsm2r::plot(qsm, col = "salmon4", lit = TRUE)
# plot shade of wood
plot_shade_wood(qsm, sun_dir)
# plot shading raster of wood
sun_position <- sun_movement(ISOdate(2020, 03, 22, 12, 0), latitude = 48.07, longitude = 7.60)
sun_position[,1:3] <- sun_dir
terra::plot(shade_tree(
qsm, sun_position, dummy_radiation(), resolution = 0.01,
xmin = -10, xmax = 10, ymin = -10, ymax = 10), col = c("#296682", "#81B1C4"))