Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in data.table::setnames(where, c("X", "Y")) : Can't assign 2 names to a 1 column data.table #684

Closed
FloFranz opened this issue May 16, 2023 · 5 comments
Assignees
Labels
Bug A bug in the package

Comments

@FloFranz
Copy link

FloFranz commented May 16, 2023

I have a list of laz files thinned before (name: thinned_pc_list) and want to rasterize them with the point-to-raster algorithm. For one element of the laz files list, I get the error message:

Error in data.table::setnames(where, c("X", "Y")) : Can't assign 2 names to a 1 column data.table.

When increasing the subcircle radius of the disks, the error does not appear. Also when leaving the na.fill argument, it works. So I think it's related to the lower number of NA pixels resulting from a larger subcircle radius. Here's my code:

# that works
dsm_test <- lidR::rasterize_canopy(thinned_pc_list[[3]], res = 1, algorithm = lidR::p2r(subcircle = 0.25, na.fill = lidR::tin()))

# here I get the error
dsm_test <- lidR::rasterize_canopy(thinned_pc_list[[3]], res = 1, algorithm = lidR::p2r(subcircle = 0.2, na.fill = lidR::tin()))

Why does it appear only for this one laz file and do you know a way to fix it?

@Jean-Romain
Copy link
Collaborator

It is an issue with the interpolation of missing pixels but I can't tell more without a reproducible example. Is it reproducible with internal dataset?

@Jean-Romain Jean-Romain self-assigned this May 16, 2023
@Jean-Romain Jean-Romain added the Bug A bug in the package label May 16, 2023
@FloFranz
Copy link
Author

You can find it in this repository. It happens in script cloud2dsm inside a loop (line 272-276), but I added one line of code (line 279) where you can find exactly the code above to test it. All what you need are some laz files in the folder data\raw_data\dsm_cloud and corresponding laz files containg ground points in data\raw_data\dtm_tiles. But I think it would be best if you had my files, since the problem is only with one particular laz file. Unfortunately, they are to large to push them, even when I want to push two of them. Is there another possiblity to provide you with the files (one where it works and the one where it doesn't)? Otherwise I will work on to provide you a minimal reproducible example maybe later.

@Jean-Romain
Copy link
Collaborator

Jean-Romain commented May 16, 2023

Please give me a minimal reproducible example. I'm not going to dig into 400 lines of third party code. You can upload on google drive, windows drive, dropbox or anything available to you. Storage capacity is not a problem nowadays.

@FloFranz
Copy link
Author

# read several las files into a list
filepath <- path/to/folder/with/lazfiles   # set filepath to the las files
las_files <- list.files(filepath, full.names = TRUE)

las_files_list <- c()
for (i in seq_along(las_files)) {
  
  las_file <- las_files[i]
  las <- lidR::readLAS(las_file)
  las_files_list[[i]] <- las
  
}

# calculate DSM rasters from the las files
dsm_list <- lapply(las_files_list,
                   FUN = function(x)
                     lidR::rasterize_canopy(x,
                                            res = 1,
                                            algorithm = lidR::p2r(subcircle = 0.2,
                                                                  na.fill = lidR::tin())))

I provide you two example laz files here (one where it works and the one where it doesn't). I've sent you the password by e-mail.

@Jean-Romain
Copy link
Collaborator

Fixed thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in the package
Projects
None yet
Development

No branches or pull requests

2 participants