You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用R读取NOAA下载的LAZ激光雷达文件报错求助

解决NOAA LAZ文件读取报错及替代下载方案

问题重现

从NOAA AWS S3服务器下载的LAZ点云文件,使用lidR包的readLAS()或readLAScatalog()读取时出现以下报错,甚至导致R崩溃:

WARNING: only 148 bytes until point block when trying to read 12423 bytes into header.vlrs[1].data
WARNING: only 0 bytes until point block after reading 2 of 3 vlrs. skipping remaining vlrs ...
ERROR: this file was compressed with an experimental version of laszip
ERROR: please contact 'martin.isenburg@rapidlasso.com' for assistance.
ERROR: cannot open lasreaderlas with file name 'C:\Users\SCMCKENZIE\Downloads\Test.laz'
Error: LASlib internal error. See message above.
Error in !x@PHB[["Global Encoding"]][["WKT"]] : invalid argument type

原R工作流代码:

## install and/or necessary package##
if(!require(lidR)){
  install.packages("lidR")
}

## Download Text File of URLs with point cloud files##
download.file("https://noaa-nos-coastal-lidar-pds.s3.amazonaws.com/laz/geoid18/9305/urllist9305.txt", "lidarlist.txt")
lazlist<-read.table("lidarlist.txt")
download.file(lazlist$V1[9], "Test.laz")

test<-readLAScatalog("Test.laz") # Throws Error
test<-readLAS("Test.laz") # Crashes R

解决方案

1. 改用NOAA FTP服务器下载

NOAA提供了FTP镜像服务器,可避免AWS下载的文件损坏问题:

  • 目标数据集的FTP路径:ftp://ftp.coast.noaa.gov/pub/DigitalCoast/lidar/laz/geoid18/9305/
  • 单文件下载示例:
    # 替换为你需要的文件名
    target_file <- "USGS_LPC_CA_SantaCruzCo_2018_B18_0709305.laz"
    ftp_url <- paste0("ftp://ftp.coast.noaa.gov/pub/DigitalCoast/lidar/laz/geoid18/9305/", target_file)
    # 二进制模式下载,避免文件损坏
    download.file(ftp_url, "Test_FTP.laz", mode = "wb")
    
    # 读取测试
    test <- readLAScatalog("Test_FTP.laz")
    
  • 批量获取文件列表并下载:
    if(!require(RCurl)) install.packages("RCurl")
    
    ftp_dir <- "ftp://ftp.coast.noaa.gov/pub/DigitalCoast/lidar/laz/geoid18/9305/"
    # 获取目录下所有文件
    file_list <- getURL(ftp_dir, ftp.use.epsv = FALSE, dirlistonly = TRUE)
    file_list <- strsplit(file_list, "\r\n")[[1]]
    
    # 筛选LAZ文件并下载第9个
    laz_files <- grep("\\.laz$", file_list, value = TRUE)
    download.file(paste0(ftp_dir, laz_files[9]), "Test_FTP.laz", mode = "wb")
    

2. 修复已下载的损坏文件

AWS下载的文件可能因传输模式错误损坏,重新下载时强制使用二进制模式:

download.file(lazlist$V1[9], "Test_Fixed.laz", mode = "wb")
# 校验文件完整性(可对比数据集目录下的md5sum.txt)
tools::md5sum("Test_Fixed.laz")

3. 更新lidR及依赖库

报错提示LASzip版本兼容问题,更新lidR到最新版可同步更新依赖的LASlib:

# 安装CRAN最新版
install.packages("lidR", dependencies = TRUE)

# 或安装GitHub开发版(获取最新修复)
if(!require(devtools)) install.packages("devtools")
devtools::install_github("Jean-Romain/lidR")

内容的提问来源于stack exchange,提问作者Sean McKenzie

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.07 21:13:34