# Single location
location = rgeos::gCentroid(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
)
plot(build, main = time)
plot(location, add = TRUE)
sun = shadow:::.sunLocation(location = location, sun_az = solar_pos[1,1], sun_elev = solar_pos[1,2])
sun_ray = ray(from = location, to = sun)
build_outline = as(build, "SpatialLinesDataFrame")
inter = rgeos::gIntersection(build_outline, sun_ray)
plot(sun_ray, add = TRUE, col = "yellow")
plot(inter, add = TRUE, col = "red")
shadeHeight(location, build, "BLDG_HT", solar_pos)
## Not run:
#
# # Grid
# ext = as(raster::extent(build), "SpatialPolygons")
# r = raster::raster(ext, res = 3)
# proj4string(r) = proj4string(build)
# grid = raster::rasterToPoints(r, spatial = TRUE)
# grid = sp::SpatialPointsDataFrame(grid, data.frame(grid_id = 1:length(grid)))
# height_field = "BLDG_HT"
# for(i in 1:length(grid)) {
# grid$shade_height[i] =
# shadeHeight(grid[i, ], build, height_field, solar_pos, messages = FALSE)
# }
# shade = as(grid, "SpatialPixelsDataFrame")
# shade = raster::raster(shade, layer = "shade_height")
# plot(shade, col = grey(seq(0.9, 0.2, -0.01)), main = time)
# raster::contour(shade, add = TRUE)
# plot(build, add = TRUE, border = "red")
#
# ## End(Not run)
Run the code above in your browser using DataLab