New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add RGB values #689
Comments
From the doc:
So this should work las_rgb <- merge_spatial(las, img) Yet you found a bug with automatic naming. |
Ok, but I still have a problem, > is.na(img)
class : SpatRaster
dimensions : 500, 500, 3 (nrow, ncol, nlyr)
resolution : 0.2, 0.2 (x, y)
extent : 567222.4, 567322.4, 5708785, 5708885 (xmin, xmax, ymin, ymax)
coord. ref. : ETRS89 / UTM zone 32N (EPSG:25832)
source(s) : memory
names : R, G, B
min values : FALSE, FALSE, FALSE
max values : FALSE, FALSE, FALSE Thats why With |
The |
You were right I was trying to crop the image with the bbox of the las, which did not perfectly fit with default sanpping option > bbox <- st_bbox(las)
>
>
> # crop to las extent
> img1 <- crop(img, st_as_sfc(bbox))
>
> ext(img1)
SpatExtent : 569137.4, 569147.4, 5709415.4, 5709425.2 (xmin, xmax, ymin, ymax)
> ext(las)
SpatExtent : 569137.482, 569147.434, 5709415.464, 5709425.295 (xmin, xmax, ymin, ymax)
>
> # try to add RGB
> las_rgb <- merge_spatial(sample, img1)
Error: Some points were associated with an NA RGB color. RGB cannot be NA in a LAS object. Colorization aborted.
> # crop to extented bbox
> img2 <- crop(img, st_as_sfc(bbox),snap="out")
>
> ext(img2)
SpatExtent : 569137.4, 569147.6, 5709415.4, 5709425.4 (xmin, xmax, ymin, ymax)
> ext(las)
SpatExtent : 569137.482, 569147.434, 5709415.464, 5709425.295 (xmin, xmax, ymin, ymax)
>
> # add RGB works
> las_rgb <- merge_spatial(sample, img2) Although I am wondering if it would be possible / useful to add RGB values where there is valid data only (not sure if NA is valid in las data though). |
No because NA is not a writable value in a LAS file and lidR tries to ensure that |
Makes sense, thanks! |
Fixed, attributes are no longer automatically renamed when filtering a point cloud |
Hi,
I want to merge RGB values from raster image to the las pointcloud.
Currently I tried:
But I guess there is a better way, since the intermediate
r
value seems obsolete. How would I do it properly?Also it seems strange that
plot(las_rgb, color = "RGB)
cant find RGB values when I do not runadd_lasrgb
(since I named them with lower letters), butfilter_poi
seems to recognize the lower letters as RGB values and renames them to capital RGB, which then results in two attributes for each R, G and B.The text was updated successfully, but these errors were encountered: