Skip to content

Commit

Permalink
Fix #776
Browse files Browse the repository at this point in the history
  • Loading branch information
Jean-Romain committed Sep 9, 2024
1 parent 5cb028c commit 39d1f19
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ If you are viewing this file on CRAN, please check [the latest news on GitHub](h

- Fix: #771 read VPC files with absolute path
- Enhance: `crs()` `is.empty()` and `area()` are now inherits from `terra` and no longer clash with `terra`.
- Enhance: #776 `readLAScatalog` can skipped corrupted files

## lidR v4.1.2 (Release date: 2024-07-09)

Expand Down
10 changes: 9 additions & 1 deletion R/io_readLAScatalog.R
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,13 @@ readLAScatalog <- function(folder, progress = TRUE, select = "*", filter = "", c

headers <- lapply(files, function(x)
{
header <- rlas:::lasheaderreader(x)
header <- rlas:::lasheaderreader(x)
if (length(header) == 0)
{
warning(paste0("Corrupted file ", x, " is not readable and was skipped in the LAScatalog"))
return(NULL)
}

header <- LASheader(header)
PHB <- header@PHB
names(PHB) <- phblab
Expand Down Expand Up @@ -136,6 +142,8 @@ readLAScatalog <- function(folder, progress = TRUE, select = "*", filter = "", c
})
}

rm = sapply(headers, is.null)
files = files[!rm]
headers <- data.table::rbindlist(headers)
headers$filename <- files
data.table::setDF(headers)
Expand Down

0 comments on commit 39d1f19

Please sign in to comment.