2

I am trying to use the LAScatalog engine and clip out several thousand point clouds using a shapefile. I have already run this successfully but I specified my output names using {XCENTER}_{YCENTER} which as I have come to find out isn't the best option for me. What I want is something very similar to the documentation where {_LAKENAME1} was used, in my case this will be {shotnumber} as per my file. Unfortunately, it does not recognize this name within the file and thus cannot use it as a naming convention.

enter image description here

enter image description here

1
  • Please replace screenshots with copy pasted raw text
    – JRR
    Commented Feb 22, 2022 at 22:59

1 Answer 1

1

What you are reporting is simply a little bug. When plotting with chunk = TRUE lidR tries to build the filenames but in this context it cannot. I opened an issue with a reproducible example here.

However clipping works as expected:

library(lidR)

LASfile <- system.file("extdata", "Megaplot.laz", package="lidR")
ctg = readLAScatalog(LASfile)

# Generate random spatial points
x <- runif(5, ctg$Min.X,  ctg$Max.X)
y <- runif(5, ctg$Min.Y,  ctg$Max.Y)
shotnumber <- paste0(letters[1:5], letters[10:14])
loc <- data.frame(x,y,shotnumber)
loc <- sf::st_as_sf(loc, coords = c("x", "y"))

opt_output_files(ctg) <- "clip_{shotnumber}"
loc_ctg = clip_roi(ctg, loc, radius = 10)

plot(ctg)
plot(sf::st_geometry(loc), add = T, pch = 19 )
plot(loc_ctg, add = T)

loc_ctg$filename
#> [1] "clip_aj.las" "clip_bk.las" "clip_cl.las"  "clip_dm.las"
#> [5] "clip_en.las"

Created on 2022-02-22 by the reprex package (v2.0.1)

1
  • Oh fantastic! Thank you! Good to know that is just something like that, I have been sitting here trying every which way for far too long. I greatly appreciate this
    – Connor Bax
    Commented Feb 22, 2022 at 23:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.