Skip to content

Instantly share code, notes, and snippets.

@toebR
Created June 15, 2021 18:28
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toebR/cec8f53a50820c7f22094cf40952f841 to your computer and use it in GitHub Desktop.
Save toebR/cec8f53a50820c7f22094cf40952f841 to your computer and use it in GitHub Desktop.
#a snippet for quick plots of LIDAR data in ggplot2
#Tobias Stalder
#June 2021
#load libraries
library(tidyverse)
library(rlas)
library(gg3D)
#load data
dat <- rlas::read.las(files = r"(C:\PATH\TO\FILE\lidaR_dat.las)")
#subset dataset
n <- 10
df_new <- dat[seq(1, nrow(dat), n), ] #only take every nth point
#check amount of points
nrow(df_new)
#angles
theta=0
phi=40
#plot
ggplot(df.new, aes(x=X, y=Y, z=Z, color=-Z),
size = .1, alpha = .5) +
axes_3D(theta=theta, phi=phi) +
stat_3D(theta=theta, phi=phi) +
scale_color_viridis_c() + theme_void() +
ggsave(filename = r"(C:\PATH\TO\FOLDER\lidar_scatter.png)",
width = 15, height = 15, limitsize = FALSE)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment