Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CityShadeMapper.Rproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Version: 1.0
ProjectId: 7ee5c2e7-dab2-4121-94b9-711adacf562f

RestoreWorkspace: No
SaveWorkspace: No
Expand Down
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: CityShadeMapper
Title: Generate High Resolution Shade Maps and Shaded Routes from Remote Sensing Data
Version: 0.0.1
Version: 0.0.2
Authors@R: c(
person("Francisco", "Rodríguez-Sánchez",
email = "f.rodriguez.sanc@gmail.com",
Expand All @@ -17,7 +17,7 @@ License: AGPL (>= 3)
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
LazyData: true
RoxygenNote: 7.3.1
RoxygenNote: 7.3.3
Imports:
class,
gdistance,
Expand Down
7 changes: 7 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# CityShadeMapper 0.0.2

* Added new logical argument `low.veg.as.ground` to `rasterize_lidar_cover_class()`
to decide if low vegetation should be considered ground or mixed with medium-high vegetation
(#21).


19 changes: 15 additions & 4 deletions R/rasterize_lidar_cover_class.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
#' paths to LAS/LAZ objects.
#' @param res Resolution of the resulting raster.
#' @param fill.holes Logical. Try to fill holes in lidar point classification.
#' @param low.veg.as.ground Logical. Classify low vegetation (<1 m high) as ground?
#' Default is TRUE. If FALSE, low vegetation will be grouped together with medium
#' and high vegetation.
#' @param filename Character. Output filename. Note that if a file already exists
#' with that name, it will be overwritten.
#'
Expand All @@ -24,20 +27,28 @@
rasterize_lidar_cover_class <- function(las = NULL,
res = 1,
fill.holes = TRUE,
low.veg.as.ground = TRUE,
filename = NULL) {

pts <- lidR::readLAS(las, select = "xyc", filter = "-keep_class 2 3 4 5 6 9 17")
#table(pts$Classification)
# see classes https://github.com/Pakillo/CityShadeMapper/issues/2#issuecomment-1117648511
# reclassify bridges as ground
pts$Classification[pts$Classification == 17] <- as.integer(2)
# reclassify low vegetation (<1m) as ground
pts$Classification[pts$Classification == 3] <- as.integer(2)

# reclassify low vegetation (<1m) as ground?
if (isTRUE(low.veg.as.ground)) {
pts$Classification[pts$Classification == 3] <- as.integer(2)
} else {
pts$Classification[pts$Classification == 3] <- as.integer(4)
}

# join classes 4 & 5 (vegetation > 1m high)
pts$Classification[pts$Classification == 5] <- as.integer(4)

pts.class <- lidR::pixel_metrics(pts,
func = CityShadeMapper:::max.class(Classification),
# func = CityShadeMapper:::max.class(Classification),
func = ~list(max.class = max(Classification, na.rm = TRUE)),
res = res)

if (!is.null(filename)) {
Expand All @@ -58,7 +69,7 @@ rasterize_lidar_cover_class <- function(las = NULL,
}


max.class <- function(x) {max(x, na.rm = TRUE)}
# max.class <- function(x) {max(x, na.rm = TRUE)}

fill_holes <- function(ras = NULL) {

Expand Down
5 changes: 5 additions & 0 deletions man/rasterize_lidar_cover_class.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.