在python中使用liblas和laspy读取las文件的问题
Posted
技术标签:
【中文标题】在python中使用liblas和laspy读取las文件的问题【英文标题】:problem in reading las file using liblas and laspy in python 【发布时间】:2019-08-27 17:20:10 【问题描述】:我 pip 安装了 liblas,它安装得很好,但是,当我尝试导入 liblas 时,它仍然引发了一个错误,显示在第一个错误中。
然后我 pip 安装了 laspy,它安装得很好,并尝试使用 laspy.file.File 从中读取我的 las 文件,但它再次引发了我在第二个错误中显示的错误
OSError Traceback (most recent call last)
<ipython-input-6-7ba94c832967> in <module>
----> 1 import liblas
C:\ProgramData\Anaconda3\lib\site-packages\liblas\__init__.py in <module>
1 #from .core import *
----> 2 from .core import get_version
3 from .core import las
4 version = get_version()
5 HAVE_GDAL = bool(las.LAS_IsGDALEnabled())
C:\ProgramData\Anaconda3\lib\site-packages\liblas\core.py in <module>
137 original_path = os.environ['PATH']
138 os.environ['PATH'] = "%s;%s" % (local_dlls, original_path)
--> 139 las = ctypes.CDLL(lib_name)
140
141 def free(m):
C:\ProgramData\Anaconda3\lib\ctypes\__init__.py in __init__(self, name, mode, handle, use_errno, use_last_error)
354
355 if handle is None:
--> 356 self._handle = _dlopen(self._name, mode)
357 else:
358 self._handle = handle
OSError: [WinError 126] The specified module could not be found
LaspyException Traceback (most recent call last)
<ipython-input-5-20f5fbf35bba> in <module>
----> 1 inFile = File('2_DLL.las', mode='r')
C:\ProgramData\Anaconda3\lib\site-packages\laspy\file.py in __init__(self, filename, header, vlrs, mode, in_srs, out_srs, evlrs)
62 self.in_srs = in_srs
63 self.out_srs = out_srs
---> 64 self.open()
65
66 def open(self):
C:\ProgramData\Anaconda3\lib\site-packages\laspy\file.py in open(self)
73 ## Make sure we have a header
74 if self._header is None:
---> 75 self._reader = base.Reader(self.filename, mode=self._mode)
76 self._header = self._reader.get_header()
77 else:
C:\ProgramData\Anaconda3\lib\site-packages\laspy\base.py in __init__(self, filename, mode, header, vlrs, evlrs)
271 self.padded = False
272 if self.mode in ("r", "r-"):
--> 273 self.setup_read_write(vlrs,evlrs, read_only=True)
274 return
275 elif self.mode == "rw":
C:\ProgramData\Anaconda3\lib\site-packages\laspy\base.py in setup_read_write(self, vlrs, evlrs, read_only)
300 self.data_provider.open(open_mode)
301 self.data_provider.map()
--> 302 self.header_format = laspy.util.Format("h" + self.grab_file_version())
303 self.get_header(self.grab_file_version())
304 self.populate_vlrs()
C:\ProgramData\Anaconda3\lib\site-packages\laspy\util.py in __init__(self, fmt, overwritable, extra_bytes, extradims)
150 "EVLR", "h1.0", "h1.1", "h1.2", "h1.3", "h1.4",
151 "extra_bytes_struct", "None")):
--> 152 raise LaspyException("Invalid format: " + str(fmt))
153 if self.fmt == None:
154 return
LaspyException: Invalid format: h82.83
【问题讨论】:
【参考方案1】:先决条件 Python 绑定需要安装 libLAS 基础 C 和 C++ 库。从http://liblas.org/download.html 获取库的源代码副本,并按照http://liblas.org/compilation.html 的编译说明构建和安装库。
【讨论】:
以上是关于在python中使用liblas和laspy读取las文件的问题的主要内容,如果未能解决你的问题,请参考以下文章
为啥在将 liblas 链接到 Qt 后出现未定义的参考错误?