Skip to content

Instantly share code, notes, and snippets.

@ptompalski
Created October 13, 2021 16:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ptompalski/1aea3e7764b73703a24437adc3c1ed0e to your computer and use it in GitHub Desktop.
Save ptompalski/1aea3e7764b73703a24437adc3c1ed0e to your computer and use it in GitHub Desktop.
plot a crossection of a point cloud
# function to plot a crossection of a point cloud
# works with lidR package
plot_crossection <- function(las,
p1 = c(min(las@data$X), mean(las@data$Y)),
p2 = c(max(las@data$X), mean(las@data$Y)),
width = 4, colour_by = NULL)
{
colour_by <- enquo(colour_by)
data_clip <- clip_transect(las, p1, p2, width)
p <- ggplot(data_clip@data, aes(X,Z)) + geom_point(size = 0.5) + coord_equal() + theme_minimal()
if (!is.null(colour_by))
p <- p + aes(color = !!colour_by) + labs(color = "")
return(p)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment