Title: | Generate High Resolution Shade Maps and Shaded Routes from Remote Sensing Data |
---|---|
Description: | CityShadeMapper can generate high resolution shade maps (e.g. for every square meter and every hour of the year) for any city or town from open remote sensing (LiDAR) data. CityShadeMapper can also return optimal routes within any two points in the city that maximise the amount of shade for pedestrians. |
Authors: | Francisco Rodríguez-Sánchez [aut, cre] , Jesús Sánchez-Dávila [aut] |
Maintainer: | Francisco Rodríguez-Sánchez <[email protected]> |
License: | AGPL (>= 3) |
Version: | 0.0.1 |
Built: | 2024-11-20 04:53:20 UTC |
Source: | https://github.com/Pakillo/CityShadeMapper |
Generate height raster from LiDAR data
calc_heights_from_lidar( las = NULL, res = 1, ground = FALSE, thresholds = c(0, 2, 5, 10, 20), filename = NULL, ... )
calc_heights_from_lidar( las = NULL, res = 1, ground = FALSE, thresholds = c(0, 2, 5, 10, 20), filename = NULL, ... )
las |
LiDAR data (a |
res |
Spatial resolution of the raster |
ground |
Logical. Calculate ground height in addition to canopy/roof heights? |
thresholds |
Set of height thresholds (see |
filename |
Character. Output filename. Note that if a file already exists with that name, it will be overwritten. |
... |
further arguments to |
SpatRaster with height data
## Not run: heights <- calc_heights_from_lidar(PlazaNueva()) ## End(Not run)
## Not run: heights <- calc_heights_from_lidar(PlazaNueva()) ## End(Not run)
Calculate shaded route
calc_shaded_route(origin = NULL, destination = NULL, shaderas = NULL)
calc_shaded_route(origin = NULL, destination = NULL, shaderas = NULL)
origin |
A character vector describing an address, an |
destination |
A character vector describing an address, an |
shaderas |
Shade raster |
A SpatVector object with the optimal route
## Not run: shaderas <- terra::rast("/vsicurl/https://zenodo.org/record/7213637/files/m7_h13_ground.tif") shade.route <- calc_shaded_route("Plaza Nueva, Sevilla", "Mateos Gago, Sevilla", shaderas) library(leaflet) leaflet(sf::st_as_sf(shade.route)) |> leaflet::addWMSTiles(baseUrl = "https://www.ign.es/wms-inspire/ign-base", layers = "IGNBaseTodo-nofondo") |> leaflet::addTiles(urlTemplate = "https://mapasdesombra.github.io/Sevilla-jul-ground/13/{z}/{x}/{y}.png", options = leaflet::tileOptions(minZoom = 15, maxZoom = 18, tms = TRUE, opacity = 0.4)) |> addPolylines(weight = 8, opacity = 0.8) ## End(Not run)
## Not run: shaderas <- terra::rast("/vsicurl/https://zenodo.org/record/7213637/files/m7_h13_ground.tif") shade.route <- calc_shaded_route("Plaza Nueva, Sevilla", "Mateos Gago, Sevilla", shaderas) library(leaflet) leaflet(sf::st_as_sf(shade.route)) |> leaflet::addWMSTiles(baseUrl = "https://www.ign.es/wms-inspire/ign-base", layers = "IGNBaseTodo-nofondo") |> leaflet::addTiles(urlTemplate = "https://mapasdesombra.github.io/Sevilla-jul-ground/13/{z}/{x}/{y}.png", options = leaflet::tileOptions(minZoom = 15, maxZoom = 18, tms = TRUE, opacity = 0.4)) |> addPolylines(weight = 8, opacity = 0.8) ## End(Not run)
An example 9 x 9 meter SpatRaster with a 4 m tall building in the middle.
example_building()
example_building()
A SpatRaster.
An example 100 x 100 meter SpatRaster with a 10 m tall rectangular wall and a 4-m tall tree in the middle.
example_square()
example_square()
A SpatRaster.
An example 9 x 9 meter SpatRaster with a 4 m tall tree in the middle.
example_tree()
example_tree()
A SpatRaster.
Get sun position (declination, elevation, and azimuth) for a given day and time.
get_sun_position( lon = NULL, lat = NULL, date = NULL, hour = NULL, omit.nights = TRUE )
get_sun_position( lon = NULL, lat = NULL, date = NULL, hour = NULL, omit.nights = TRUE )
lon |
Longitude (numeric value between -180 and 180) |
lat |
Latitude (numeric value between -90 and 90) |
date |
A Date object or character giving the date in YYYY-MM-DD format (e.g. "2021-02-19"). Can be a vector too, e.g. c("2021-02-19", "2021-08-04"). Note different years have no effect on sun position calculations. |
hour |
Hour of the day. Integer number (or numeric vector) between 0 and 23 (both included). |
omit.nights |
Logical. If TRUE, sun positions will only be returned when it is daytime (i.e. nighttimes will be omitted) |
A data frame with solar elevation and azimuth per hour
as returned by solartime::computeSunPositionDoyHour()
but converted to degrees rather than radians.
sunpos <- get_sun_position(lon = -5.99, lat = 37.39, date = "2021-02-19", hour = 15) sunpos <- get_sun_position(lon = -5.99, lat = 37.39, date = c("2021-02-19", "2022-08-05"), hour = 10:14)
sunpos <- get_sun_position(lon = -5.99, lat = 37.39, date = "2021-02-19", hour = 15) sunpos <- get_sun_position(lon = -5.99, lat = 37.39, date = c("2021-02-19", "2022-08-05"), hour = 10:14)
Make leaflet shade map
leaflet_shademap( url.canopy = NULL, url.ground = NULL, url.cog = NULL, band = 1, satellite = FALSE, opacity = 0.5 )
leaflet_shademap( url.canopy = NULL, url.ground = NULL, url.cog = NULL, band = 1, satellite = FALSE, opacity = 0.5 )
url.canopy |
Character. Url pointing to shade tiles at the canopy level. |
url.ground |
Character. Url pointing to shade tiles at the ground level. |
url.cog |
Character. Url pointing to a cloud-optimised geotiff (starting with 'https://'). The COG raster must have EPSG:4326 projection. Currently not implemented. |
band |
Numeric. Band to show in multilayer rasters (only for COG). |
satellite |
Logical. Add satellite images as another layer to the map? |
opacity |
Numeric between 0 and 1. Opacity of the shade layer. |
A leaflet map
## Not run: leaflet_shademap(url.canopy = "https://mapasdesombra.github.io/Sevilla-jul-canopy/11/{z}/{x}/{y}.png") ## End(Not run)
## Not run: leaflet_shademap(url.canopy = "https://mapasdesombra.github.io/Sevilla-jul-canopy/11/{z}/{x}/{y}.png") ## End(Not run)
Calculate shade raster for given dates and hours
make_shademap( height.ras = NULL, date = NULL, hour = NULL, type = c("canopy", "ground"), cover.ras = NULL, zscale = 1, omit.nights = TRUE, filename = NULL, ... )
make_shademap( height.ras = NULL, date = NULL, hour = NULL, type = c("canopy", "ground"), cover.ras = NULL, zscale = 1, omit.nights = TRUE, filename = NULL, ... )
height.ras |
A |
date |
A Date object or character giving the date in YYYY-MM-DD format (e.g. "2021-02-19"). Can be a vector too, e.g. c("2021-02-19", "2021-08-04"). Note different years have no effect on sun position calculations. |
hour |
Hour of the day. Integer number (or numeric vector) between 0 and 23 (both included). |
type |
Character. Either 'canopy' to get illumination at the canopy/roof level, or 'ground' to get illumination at the ground level (i.e. for pedestrians). |
cover.ras |
A SpatRaster containing cover classes (ground, vegetation, buildings...).
See |
zscale |
Default |
omit.nights |
Logical. If TRUE, sun positions will only be returned when it is daytime (i.e. nighttimes will be omitted) |
filename |
Character. Output filename. Note that if a file already exists with that name, it will be overwritten. |
... |
further arguments to |
A (possibly multilayer) SpatRaster object with the intensity of illumination at each pixel for every date and time
## Not run: lidar <- PlazaNueva() heights <- calc_heights_from_lidar(lidar) shaderas <- make_shademap(heights, date = "2022-10-15", hour = 13) plot_shademap(shaderas, smooth = TRUE) shaderas <- make_shademap(heights, date = "2022-10-15", hour = 8:20) plot_shademap(shaderas, animate = TRUE, smooth = TRUE) shaderas <- make_shademap(heights, date = "2022-07-15", hour = 8:21) plot_shademap(shaderas, animate = TRUE, smooth = TRUE) shaderas <- make_shademap(heights, date = c("2022-07-15", "2022-10-15"), hour = 13) plot_shademap(shaderas, legend = FALSE) ## Ground-level shade maps require additional raster with cover classes lidar <- read_lidar(system.file("extdata", "PlazaNueva.laz", package = "CityShadeMapper")) cover.ras <- rasterize_lidar_cover_class(lidar) shaderas <- make_shademap(heights, date = "2022-10-15", hour = 13, type = "ground", cover.ras = cover.ras) ## End(Not run)
## Not run: lidar <- PlazaNueva() heights <- calc_heights_from_lidar(lidar) shaderas <- make_shademap(heights, date = "2022-10-15", hour = 13) plot_shademap(shaderas, smooth = TRUE) shaderas <- make_shademap(heights, date = "2022-10-15", hour = 8:20) plot_shademap(shaderas, animate = TRUE, smooth = TRUE) shaderas <- make_shademap(heights, date = "2022-07-15", hour = 8:21) plot_shademap(shaderas, animate = TRUE, smooth = TRUE) shaderas <- make_shademap(heights, date = c("2022-07-15", "2022-10-15"), hour = 13) plot_shademap(shaderas, legend = FALSE) ## Ground-level shade maps require additional raster with cover classes lidar <- read_lidar(system.file("extdata", "PlazaNueva.laz", package = "CityShadeMapper")) cover.ras <- rasterize_lidar_cover_class(lidar) shaderas <- make_shademap(heights, date = "2022-10-15", hour = 13, type = "ground", cover.ras = cover.ras) ## End(Not run)
Calculate shade map at the ground level
make_shademap_ground(shademap.canopy = NULL, cover.ras = NULL, filename = NULL)
make_shademap_ground(shademap.canopy = NULL, cover.ras = NULL, filename = NULL)
shademap.canopy |
A SpatRaster with the illumination at the canopy level,
made with |
cover.ras |
A SpatRaster containing cover classes (ground, vegetation, buildings...).
See |
filename |
Character. Output filename. Note that if a file already exists with that name, it will be overwritten. |
A (possibly multilayer) SpatRaster object with the intensity of illumination at the ground level
## Not run: lidar <- read_lidar(system.file("extdata", "PlazaNueva.laz", package = "CityShadeMapper")) cover.ras <- rasterize_lidar_cover_class(lidar) shaderas.canopy <- make_shademap(heights, date = "2022-10-15", hour = 13) shaderas.ground <- make_shademap_ground(shaderas.canopy, cover.ras) ## Alternatively, call make_shademap directly: heights <- calc_heights_from_lidar(lidar) shaderas.ground <- make_shademap(heights, date = "2022-10-15", hour = 13, type = "ground", cover.ras = cover.ras) ## End(Not run)
## Not run: lidar <- read_lidar(system.file("extdata", "PlazaNueva.laz", package = "CityShadeMapper")) cover.ras <- rasterize_lidar_cover_class(lidar) shaderas.canopy <- make_shademap(heights, date = "2022-10-15", hour = 13) shaderas.ground <- make_shademap_ground(shaderas.canopy, cover.ras) ## Alternatively, call make_shademap directly: heights <- calc_heights_from_lidar(lidar) shaderas.ground <- make_shademap(heights, date = "2022-10-15", hour = 13, type = "ground", cover.ras = cover.ras) ## End(Not run)
LiDAR data of Plaza Nueva in Sevilla, Spain. Data provided by LiDAR-PNOA 2018 CC-BY 4.0 scne.es.
PlazaNueva()
PlazaNueva()
A LAScatalog.
Plot shade map
plot_shademap(shade.ras = NULL, legend = TRUE, animate = FALSE, ...)
plot_shademap(shade.ras = NULL, legend = TRUE, animate = FALSE, ...)
shade.ras |
A |
legend |
Logical. Show legend? |
animate |
Logical. Show animation of all the |
... |
Further arguments to |
A static or animated plot.
Get raster of cover classification from lidar points
rasterize_lidar_cover_class( las = NULL, res = 1, fill.holes = TRUE, filename = NULL )
rasterize_lidar_cover_class( las = NULL, res = 1, fill.holes = TRUE, filename = NULL )
las |
A |
res |
Resolution of the resulting raster. |
fill.holes |
Logical. Try to fill holes in lidar point classification. |
filename |
Character. Output filename. Note that if a file already exists with that name, it will be overwritten. |
A SpatRaster with the classification of cover types: 2 = ground (including low vegetation < 1m) 4 = high vegetation (> 1m) 6 = buildings 9 = water and NA values. Note that points classified as bridges (class 17) will be reclassified as ground.
## Not run: pza <- system.file("extdata", "PlazaNueva.laz", package = "CityShadeMapper") pza.cover <- rasterize_lidar_cover_class(pza) ## End(Not run)
## Not run: pza <- system.file("extdata", "PlazaNueva.laz", package = "CityShadeMapper") pza.cover <- rasterize_lidar_cover_class(pza) ## End(Not run)
Read LiDAR data
read_lidar(folder = NULL, select = "xyz", filter = "-drop_class 7", ...)
read_lidar(folder = NULL, select = "xyz", filter = "-drop_class 7", ...)
folder |
Character. Path to folder containing las/laz files. Can also be a vector of file paths. |
select |
Character. Point attributes to read from the las/laz files.
Use |
filter |
Character. Optional. Use if you want to filter out some data points.
For example, we could filter out noisy data points (class = 7) using
|
... |
Further arguments for |
LAScatalog object with LiDAR data
## Not run: las <- system.file("extdata", "PlazaNueva.laz", package = "CityShadeMapper") lidar <- read_lidar(las) ## End(Not run)
## Not run: las <- system.file("extdata", "PlazaNueva.laz", package = "CityShadeMapper") lidar <- read_lidar(las) ## End(Not run)