ray: Line between two points

View source: R/ray.R

rayR Documentation

Line between two points

Description

The function connects two points into a line segment.

Usage

ray(from, to)

Arguments

from

A SpatialPoints* object specifying origin.

to

A SpatialPoints* object specifying destination.

Value

A SpatialLines object.

Examples

# ctr = rgeos::gCentroid(build)
ctr = as(sf::st_centroid(sf::st_union(sf::st_geometry(sf::st_as_sf(build)))), "Spatial")
angles = seq(0, 359, 20)
sun = mapply(
  shadow:::.sunLocation,
  sun_az = angles,
  MoreArgs = list(
    location = ctr,
    sun_elev = 10)
)
rays = mapply(ray, MoreArgs = list(from = ctr), to = sun)
rays$makeUniqueIDs = TRUE
rays = do.call(rbind, rays)
plot(rays)
sun = do.call(rbind, sun)
text(sun, as.character(angles))


michaeldorman/shadow documentation built on Sept. 10, 2023, 4:17 a.m.