1

I used the following commands as mentioned in the answer here

ctg = readLAScatalog(...) p = read.table(...) opt_output_file <- "/folder/AOI_{Id_placett}" aois = lasclipCircle(ctg, p$x, p$y, 10)

The opt_output_file <- "/folder/AOI_{Id_placett}" command only created a variable named 'opt_output_file'. Apparently, this variable was not used in the following clipping command and the results was a lascatalog named 'aois' only. No files were written.

I then used the ABA approach. Here it seems to have been used differently, as follows:

ctg <- readLAScatalog(...)
plots <- st_read("...")
opt_output_files(ctg) <- paste0(tempdir(), "/{Id_placett}") #Id_placett is the column name
plots_ALS_clipped <- lasclip(ctg, plots, radius=15)

The lascatalog i.e. ctg is mentioned in the command opt_output_files(ctg). This seems to have worked and a temporary folder was created. But there are two issues that I encountered:

1) If I replace tempdir() with another path, I don't see any files in the location specified by me. There are some files (not all clipped plots) in the RtmpSQSLrf folder shown below. In the ABA example, it was mentioned that the clipped plots will be saved on the HDD

2) {/Id_placette} is used as a column name to retain the names of the clipping polygons. But all the clipped las entities in the lascatalog end with the column name i.e. "Id_placett". I thought they are supposed to end with corresponding clipping polygon names.

For example, plots_ALS_clipped@data$filename returns the following (showing only first few entries):

 [1] "\\AppData\\Local\\Temp\\RtmpSQSLrf\\Id_placett.las"
 [2] "\\AppData\\Local\\Temp\\RtmpSQSLrf\\Id_placett.las"
 [3] "\\AppData\\Local\\Temp\\RtmpSQSLrf\\Id_placett.las"
 [4] "\\AppData\\Local\\Temp\\RtmpSQSLrf\\Id_placett.las"
 [5] "\\AppData\\Local\\Temp\\RtmpSQSLrf\\Id_placett.las"

As you can see, all the clipped areas in the plots_ALS_clipped are named as 'Id_placett'

1
  • Please edit your question to be more accurate. I do not understand if p is a data.frame or not. If plots is a SpatialPointsDataFrame of not. You didn't tell us the names of your columns neither in p nor in plots. Tell us more about your objects.
    – JRR
    Commented Jan 14, 2020 at 12:59

1 Answer 1

2
opt_output_file(ctg) <- "/folder/AOI_{Id_placett}"
aois = lasclipCircle(ctg, p$x, p$y, 10)

The above mentioned code cannot work because lasclipCircle() has no way to know where to find Id_placett. lasclipCircle only support regular templates such as XLEFT, YBOTTOM, ID, XCENTER and so on.

opt_output_files(ctg) <- paste0(tempdir(), "/{Id_placett}") #Id_placett is the column name
plots_ALS_clipped <- lasclip(ctg, plots, radius=15)

The above mentioned code is good. It is expected to work. A bug has been fixed in v2.2.0. Please update if not up-to-date. Maybe your trouble come from that. Anyway it indeed puts the output in tempdir().

{Id_placett} is used as a column name to retain the names of the clipping polygons. But all the clipped las entities in the LAScatalog end with the column name i.e. Id_placett

It should work. Update and if it still does not work please provide a reproducible example. And check twice if it is Id_placet, Id_placett or Id_placette. Your used each variation

4
  • The problem related to the path is solved. I am able to specify the location of the output. However, there is only one file named 'Id_placett.las' in the output folder. Seems like the other files which have the same name were overwritten. I used opt_output_files(ctg) <- paste0(pth, "/{colnames(plots)[1]}") to extract the column name from the shape file and join it to the path. Please let me know if this description is clear. Thanks!
    – K_D
    Commented Jan 14, 2020 at 15:08
  • Do not try to put something else than what is allowed. In your case {Id_placett}. It won't crash but it won't give you the expected result. If it does not work edit your question with a fully (minimal) reproducible code and summary of your objects. We cannot guess what you did wrong.
    – JRR
    Commented Jan 14, 2020 at 15:16
  • Following the method shown in the ABA example for lidR, when I use only {Id_placett}, I get the error object 'Id_placett' not found. In any case, I will try to provide a reproducible example!
    – K_D
    Commented Jan 14, 2020 at 15:30
  • Solved! There was a problem during the installation of the update. Fixed it and worked. Thanks for the help!
    – K_D
    Commented Jan 15, 2020 at 10:28

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.