Learn R Programming

shadow (version 0.2.0)

shadeImageWall: Create an image of wall shading

Description

The function divides a given wall to a grid of rectangular 'cells', then finds whether each cell is shaded (at least partially) or not, by repeatedly calling shadeHeight on regular sample points along the wall facade.

Usage

shadeImageWall(seg, seg_height_field, build, build_height_field, solar_pos, sample_dist = 1, shift_dist = 0.01, messages = TRUE)

Arguments

seg
A SpatialLinesDataFrame object representing the wall footprint
seg_height_field
The name of the column with wall height in seg
build
A SpatialPolygonsDataFrame object specifying the buildings outline.
build_height_field
The name of the column with building height in build
solar_pos
A matrix with two columns: solar azimuth (in degrees from North), and elevation
sample_dist
Horizontal sampling distance of seg for creating the shade image
shift_dist
The distance for shifting the examined locations away from wall to avoid self-shading. Default is 1 cm.
messages
Whether a message regarding distance units of the CRS should be displayed.

Value

A data.frame representing the shade image of seg, with the following columns:
  • solar_pos_row The corresponding sun position (i.e. the respective row in the solar_pos matrix
  • width The horizontal distance along wall facade, from left to right, with 0 representing the left 'side' of the wall (when the viewer stands in front of it)
  • height_upper, height_ctr, height_lower

Examples

Run this code

data(build)
time = as.POSIXct("2004-12-24 12:30:00", tz = "Asia/Jerusalem")
solar_pos = maptools::solarpos(
  matrix(c(34.7767978098526, 31.9665936050395), ncol = 2),
  time
)
seg = shadow::toSeg(build[2, ])[5, ]

# Show wall position on a map
plot(build)
plot(seg, add = TRUE, col = "red", lwd = 3)

# Calculate wall 'image'
img = shadow::shadeImageWall(
  seg = seg,
  seg_height_field = "BLDG_HT",
  build = build,
  build_height_field = "BLDG_HT",
  solar_pos = solar_pos,
  sample_dist = 1,
  shift_dist = 0.01
)

# Plot wall image
z = reshape2::acast(img, width ~ height_ctr, value.var = "shade")
image(
  x = sort(unique(img$width)),
  y = sort(unique(img$height_ctr)),
  z = z,
  asp = 1, axes = FALSE, frame.plot = FALSE,
  xlab = "Ground distance (m)", ylab = "Height (m)",
  col = c("yellow", "grey")
)
rect(
  xleft = min(img$width) - max(diff(sort(img$width)))/2,
  ybottom = min(img$height_ctr) - max(diff(sort(img$width)))/2,
  xright = max(img$width) + max(diff(sort(img$width)))/2,
  ytop = max(img$height_ctr) + max(diff(sort(img$width)))/2
)
axis(side = 1, labels = TRUE)
axis(side = 2, labels = TRUE)

Run the code above in your browser using DataLab