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

使用pylas.lasmmap读取.LAS文件报错,pylas.read遇内存错误

使用pylas.lasmmap读取LAS文件报错AttributeError,pylas.read报MemoryError

报错信息

Traceback (most recent call last):
  File "g:\Division Nät\Anläggningar\NAG\VERKSAMHET\Verktyg\Python\Hantera laserdata\test.py", line 35, in <module>
    las = pylas.lasmmap.LasMMAP(strLAS)
  File "C:\Users\repa\AppData\Roaming\Python\Python39\site-packages\pylas\lasmmap.py", line 47, in __init__
    self.points_data = record.PackedPointRecord.from_buffer(
  File "C:\Users\repa\AppData\Roaming\Python\Python39\site-packages\pylas\point\record.py", line 282, in from_buffer
    points_dtype = point_format.dtype
AttributeError: 'int' object has no attribute 'dtype'
PS G:\Division Nät\Anläggningar\NAG\VERKSAMHET\Verktyg\Python\Hantera laserdata> 

我的代码

#import package

import pylas.lasmmap

#set path
path = r'C:/mypath/lasfile.las'

#read las
las = pylas.lasmmap.lasMMAP(path)

补充情况

尝试用pylas.read读取同一文件时,出现MemoryError。


解决办法

  • 先检查并升级pylas版本,旧版本的LasMMAP处理部分LAS文件(尤其是非标准点格式或超大文件)时存在已知bug:
    pip install --upgrade pylas
    
  • 升级后若仍报错,尝试显式以二进制模式打开文件后传入LasMMAP,避免默认模式的潜在问题:
    import pylas.lasmmap
    
    path = r'C:/mypath/lasfile.las'
    with open(path, 'rb') as f:
        las = pylas.lasmmap.LasMMAP(f)
    
  • 针对MemoryError,LasMMAP本就是为大文件设计的内存映射方案,升级版本后通常可解决;若仍有问题,改用分块读取方式处理:
    import pylas
    
    path = r'C:/mypath/lasfile.las'
    with pylas.open(path) as f:
        for points in f.chunk_iterator(1_000_000):  # 每次读取100万点
            # 在此处理当前块的点数据
            print(len(points))
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.19 05:58:18