Skip to contents

In the active rgl device select a line on the 3d surface by clicking on start and end-point (order matters). These points define the beginning and end of a line segment. The line segment is drawn on the mask of the x3p object. The line object is returned as part of the x3p object, if line_result is set to TRUE

Usage

x3p_extract_profile(
  x3p,
  col = "#FF0000",
  update = TRUE,
  line_result = "equi-spaced",
  scale_to = NA,
  multiply = 5,
  linewidth = 1
)

Arguments

x3p

x3p file

col

character value of the selection color

update

boolean value, whether the rgl window should be updated to show the selected circle

line_result

enhance result by a data frame of the line: NULL for no, "raw" for data frame of original x and y (in the mask) and projected x onto the line, "equi-spaced" (default) returns a data frame with equispaced x values after fitting a loess smooth to the raw values. Note that variable x indicates the direction from first click (x=0) to the second click (max x).

scale_to

numeric value of the resolution in the returned line. Only applies to equi-spaced line_result.

multiply

integer value, factor to multiply surface values. Only applied if update is true. Defaults to 5,

linewidth

line width of the extracted line. Defaults to 1.

Value

x3p file with identified line in the mask. Depending on the setting of line_result additional information on the line is attached as a data frame.

Examples

if (FALSE) { # \dontrun{
if (interactive) {
  x3p <- x3p_read(system.file("sample-land.x3p", package="x3ptools"))
  x3p %>% image_x3p(size=dim(x3p$surface.matrix), multiply=1, zoom=.3)
  x3p <- x3p_extract_profile(x3p, update=TRUE, col="#FFFFFF") 
  x3p$line_df %>% 
    ggplot(aes(x = x, y = value)) + geom_line() 
 
 x3p$line_df$y <- 1      
 sigs <- bulletxtrctr::cc_get_signature(ccdata = x3p$line_df, 
   grooves = list(groove=range(x3p$line_df$x)), span1 = 0.75, span2 = 0.03)
 sigs %>% 
   ggplot(aes(x = x)) + 
     geom_line(aes(y = raw_sig), colour = "grey50") +
     geom_line(aes(y = sig), size = 1) +
     theme_bw() 
}} # }