A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/r-lidar/lidR/issues/545 below:

merge_spatial adds three times first band instead of RGB · Issue #545 · r-lidar/lidR · GitHub

When I try to add RGB colour values from an image to a pointcloud it returns the las file with same values (from first band) in red green and blue attribute.

las_rgb <- merge_spatial(las, img)
head(las_rgb@data[,c("R","G","B")])
#>        R     G     B
#> 1: 34181 34181 34181
#> 2: 29555 29555 29555
#> 3: 38807 38807 38807
#> 4: 34181 34181 34181
#> 5: 37522 37522 37522
#> 6: 11051 11051 11051

When I do this separately for each band the result is as expected:

las_rgb <- merge_spatial(las, img[[1]], attribute = "r")
las_rgb <- merge_spatial(las_rgb, img[[2]], attribute = "g")
las_rgb <- merge_spatial(las_rgb, img[[3]], attribute = "b")
las_rgb <- add_lasrgb(las_rgb, as.integer(las_rgb$r), as.integer(las_rgb$g), as.integer(las_rgb$b))
head(las_rgb@data[,c("R","G","B")])
#>        R     G     B
#> 1: 34181 32896 28013
#> 2: 29555 27499 24672
#> 3: 38807 35466 30583
#> 4: 34181 31611 24672
#> 5: 37522 35209 30840
#> 6: 11051 11822 13107
str(img)
#> Formal class 'SpatRaster' [package "terra"] with 1 slot
#>   ..@ ptr:Reference class 'Rcpp_SpatRaster' [package "terra"] with 20 fields
#>   .. ..$ depth    : num [1:3] 0 0 0
#>   .. ..$ extent   :Reference class 'Rcpp_SpatExtent' [package "terra"] with 2 fields
#>  .. .. ..$ valid : logi TRUE
#>   .. .. ..$ vector: num [1:4] 346000 347000 5941000 5942000
#>   .. .. ..and 28 methods, of which 14 are  possibly relevant:
#>   .. .. ..  align, as.points, ceil, compare, deepcopy, finalize, floor, initialize,
#>   .. .. ..  intersect, round, sample, sampleRandom, sampleRegular, union
#>   .. ..$ filenames: chr ""
#>   .. ..$ hasRange : logi [1:3] TRUE TRUE TRUE
#>  .. ..$ hasTime  : logi FALSE
#>   .. ..$ hasUnit  : logi FALSE
#>   .. ..$ hasValues: logi TRUE
#>   .. ..$ inMemory : logi TRUE
#>   .. ..$ messages :Reference class 'Rcpp_SpatMessages' [package "terra"] with 2 fields
#>   .. .. ..$ has_error  : logi FALSE
#>   .. .. ..$ has_warning: logi FALSE
#>   .. .. ..and 18 methods, of which 4 are  possibly relevant:
#>   .. .. ..  finalize, getError, getWarnings, initialize
#>   .. ..$ names    : chr [1:3] "R" "G" "B"
#>   .. ..$ origin   : num [1:2] 0 0
#>   .. ..$ range_max: num [1:3] 255 255 255
#>   .. ..$ range_min: num [1:3] 14 15 13
#>   .. ..$ res      : num [1:2] 0.2 0.2
#>   .. ..$ rgb      : logi TRUE
#>   .. ..$ rgbtype  : chr "rgb"
#>   .. ..$ time     : num [1:3] 0 0 0
#>   .. ..$ timestep : chr "seconds"
#>   .. ..$ units    : chr [1:3] "" "" ""
#>   .. ..$ valueType: int [1:3] 0 0 0

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4