Skip to content
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

Scale Bar when displaying point cloud. #224

Closed
Selenachav opened this issue Feb 18, 2019 · 5 comments
Closed

Scale Bar when displaying point cloud. #224

Selenachav opened this issue Feb 18, 2019 · 5 comments
Assignees
Labels
Feature request Asking for a new feature
Milestone

Comments

@Selenachav
Copy link

Is there a way to get a scale bar that shows the color and its corresponding height when I process and display my point cloud? or is this more of an R Studio question to ask?

@Jean-Romain Jean-Romain self-assigned this Feb 18, 2019
@Jean-Romain Jean-Romain added the Feature request Asking for a new feature label Feb 18, 2019
@Jean-Romain
Copy link
Collaborator

Well this is actually an rgl question. The answer is probably yes but I don't know how.

One simple solution is:

LASfile <- system.file("extdata", "Megaplot.laz", package="lidR")
las     <- readLAS(LASfile, select = "xyz")

plot(las)
axis3d("z", pos = c(0, 0, NA), col = "white" )

But to add a scale color bar it is more complex. Here an ugly solution:

plot(las)
rgl::bgplot3d( 
  fields::image.plot(
    legend.only = TRUE, 
    legend.args = list(text='Z'), 
    zlim = c(min(las$Z), max(las$Z)), 
    col = height.colors(50)
  )
) 

If you find a way (link to forum, source code or any) to add this feature I will add it for sure.

Jean-Romain added a commit that referenced this issue Feb 18, 2019
@Selenachav
Copy link
Author

Thank you.
I have posted my question on rgl forum as well.
But your "ugly solution" worked out well for what I need the scale bar for.

Also, I have not really used the lidR package since it been updated when you refer to "system.file" is that just the location of where my las file is?

@Jean-Romain
Copy link
Collaborator

system.file returns user specific path to dataset provided with the package. To me its "/home/jr/R/x86_64-pc-linux-gnu-library/3.5/lidR/extdata/Megaplot.laz" but it is something else for you.

@Jean-Romain
Copy link
Collaborator

Here a not too bad solution I could implement.

library(lidR)
LASfile <- system.file("extdata", "Megaplot.laz", package="lidR")
las     <- readLAS(LASfile, select = "xyzi")

trim = 90
grad = heat.colors(50)
col  = "Intensity"

f = tempfile(fileext = ".png")
png(f, 1920, 1080, bg = "black")
par(col.axis = "white")
fields::image.plot(
  legend.only = TRUE,
  legend.width = 2.5,
  legend.args = list(text='Z', col = "white"), 
  zlim = c(min(las@data[[col]]), min(max(las@data[[col]]), trim)), 
  col = grad)
dev.off()

plot(las, color = "Intensity", trim = trim, colorPalette = grad)
rgl::bg3d(texture = f, col = "white")

@Jean-Romain Jean-Romain added this to the v2.1.0 milestone Feb 21, 2019
Jean-Romain added a commit that referenced this issue Feb 21, 2019
@Jean-Romain
Copy link
Collaborator

I added an argument legend = TRUE

plot(las, axis = TRUE, legend = TRUE)

Work best in full screen with a 1920 x 1080 monitor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature request Asking for a new feature
Projects
None yet
Development

No branches or pull requests

2 participants