Learn R Programming

shadow (version 0.2.0)

shadePropWall: Shaded proportion of building walls

Description

Calculates the shaded proportion of a segment (usually representing a building wall), given the segment vertical height as well as the outlines and heights of obstacles (usually buildings).

Usage

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

Arguments

seg
A SpatialLinesDataFrame object where each feature is a single segment representing a wall.
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 the solar azimuth (in degrees from North), and elevation
sample_dist
Distance between sampling points along wall
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

Proportion of shaded area of the given segment.

Examples

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

# Calculate shade proportion for walls 5-10 of 2nd building
props = shadePropWall(
  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
plot(build)
plot(seg, add = TRUE, col = "red", lwd = 2)
raster::text(rgeos::gCentroid(seg, byid = TRUE), round(props, 2), cex = 0.75)

Run the code above in your browser using DataLab