1. python las读取与写入

用laspy库: https://pypi.org/project/laspy/

获取las、laz的规格、点数据格式,点数据的具体字段名称,具体的点数据
解析las、laz头文件区、点数据区的所有字段

参考:https://readthedocs.org/projects/laspy/
参考:https://pylas.readthedocs.io/en/latest/installation.html

pip install laspy
from laspy.file import Filedef main():f = File("E:/dataTes/1001140020191217.las", mode='r')# 查看点云的点格式及字段名称print('\nPoint Of Data Format: ', f.header.data_format_id)print("\tExamining Point Format: ", end=" ")for spec in f.point_format:print(spec.name, end=", ")print('\noffset: ', f.header.offset)  # 偏移量print('scale: ', f.header.scale)  # 比例因子print('min: ', f.header.min)  # x、y、z 的最小值print('max: ', f.header.max)  # x、y、z 的最大值print('file_signature: ', f.header.file_signature)  # 文件标识print('Point Of Data Format: ', f.header.data_format_id)  # 点格式print('data_record_length: ', f.header.data_record_length)  # 点个数print('FileCreateDay+Year: ', f.header.date)print()print('f.x: ', f.x)print('f.y: ', f.y)print('f.z: ', f.z)print('f.intensity: ', f.intensity)print('f.gps_time: ', f.gps_time)print('f.raw_classification: ', f.raw_classification)print()# print('f.user_data: ', f.user_data)# print('f.flag_byte: ', f.flag_byte)# print('f.Color: ', f.red, f.green, f.blue)# print('file_source_id: ', f.header.file_source_id)# print('Major_Minor version: ', f.header.version, str(f.header.version_major) + '.' + str(f.header.version_minor))# print('Generation Software: ', f.header.software_id)# print('system_id: ', f.header.system_id)# print('Header Size: ', f.header.header_size)# print('file_global_encoding: ', f.header.global_encoding)# print('gps_time_type: ', f.header.gps_time_type)# print('guid: ', f.header.guid)print()# print('f.edge_flight_line: ', f.edge_flight_line)# print('f.return_num: ', f.return_num)# print('f.classification: ', f.classification)# print('f.scan_angle_rank: ', f.scan_angle_rank)# print('f.scan_dir_flag: ', f.scan_dir_flag)# print('f.num_returns: ', f.num_returns)# print('pt_src_id: ', f.pt_src_id)f.close()if __name__ == "__main__":main()

2. las的压缩,.las转.laz,.laz转.las

las点云的无损压缩:将.las转为.laz,压缩率可达15%,空间占用减少85%;

需要俩个模块

pip install pylas
pip install lazrs

参考:https://gis.stackexchange.com/questions/332366/reading-laz-file-in-python-directly
pylas官方文档: https://pylas.readthedocs.io/en/latest/installation.html

import pylas
import time# laz 转 las
end0 = time.time()
las = pylas.read('E:/dataTes/1001117.laz')
las = pylas.convert(las)
las.write('E:/dataTes/1001117_laz2las.las')
end1 = time.time()
print("laz2las 耗时:%.2f秒" % (end1 - end0))
print('------------end1------------')# las 转 laz
las1 = pylas.read('E:/dataTes/1001147.las')
las1 = pylas.convert(las1)
las1.write('E:/dataTes/1001147_las2laz.laz')
end2 = time.time()
print("las2laz 耗时:%.2f秒" % (end2 - end1))
print('---------end----------')

3. laspy读取.laz

参考:https://stackoverflow.com/questions/49500149/laspy-cannot-find-laszip-when-is-installed-from-source-laszip-is-in-path

有用到(lasTools的laszip.exe以及dll)
windows下需要往Path环境变量里添加自己下载的lasTools的bin目录;
lasTools下载: https://github.com/m-schuetz/LAStools

from laspy.file import File
import osdef main():# 最重要的后边要有 E:\Las\LAStools\bin; lasTools中laszip.exe的路径print(os.environ["PATH"])# E:\python\lib\site-packages\pywin32_system32;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\ProgramData\Oracle\Java\javapath;D:\jdk181\bin;D:\hadoop-common-2.2.0\bin;C:\Windows\vrv\common\vSSLFltSvc;D:\apache-maven-3.5.3\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;D:\dnProject\scala-2.11.8\scala-2.11.8\bin;D:\svnSsrver\bin;D:\apache-maven-3.5.3\bin;E:\PCL 1.8.1\bin;E:\PCL 1.8.1\3rdParty\OpenNI2\Tools;E:\PCL 1.8.1\3rdParty\VTK\bin;E:\python\Scripts\;E:\python\;C:\Users\sunmeina\AppData\Local\Microsoft\WindowsApps;E:\PCL 1.8.1\bin;C:\Users\sunmeina\AppData\Local\BypassRuntm;E:\cmake\bin;E:\python\lib\site-packages\numpy\.libs;E:\Las\LAStools\bin;f = File("E:/dataTes/1001140020191217_las2laz.laz", mode='r')# 查看点云的点格式及字段名称print('\nPoint Of Data Format: ', f.header.data_format_id)print("\tExamining Point Format: ", end=" ")for spec in f.point_format:print(spec.name, end=", ")print('\noffset: ', f.header.offset)  # 偏移量print('scale: ', f.header.scale)  # 比例因子print('min: ', f.header.min)  # x、y、z 的最小值print('max: ', f.header.max)  # x、y、z 的最大值print('file_signature: ', f.header.file_signature)  # 文件标识print('Point Of Data Format: ', f.header.data_format_id)  # 点格式print('data_record_length: ', f.header.data_record_length)  # 点个数print('FileCreateDay+Year: ', f.header.date)print()print('f.x: ', f.x)print('f.y: ', f.y)print('f.z: ', f.z)print('f.intensity: ', f.intensity)print('f.gps_time: ', f.gps_time)print('f.raw_classification: ', f.raw_classification)print()f.close()if __name__ == "__main__":main()

4. pylas读取.laz

import pylasdef lazread(path):print('\n\n------------\n\n')laz = pylas.read(path)print(laz)print(laz.header)print(laz.point_format)print(laz.header.version)print(laz.point_format.id)print(laz.header.file_signature)print('offset: ', laz.header.offset_to_point_data)print('version_major: ', laz.header.version_major)print('version_minor: ', laz.header.version_minor)print('point_count: ', laz.header.point_count)print('legacy_point_count: ', laz.header.legacy_point_count)print('file_source_id: ', laz.header.file_source_id)print('global_encoding: ', laz.header.global_encoding)print('date: ', laz.header.date)print('data_record_length: ', laz.points_data.point_size)print('point_size: ', laz.header.point_size)print('point_data_record_length: ', laz.header.point_data_record_length)print('uuid: ', laz.header.uuid)print('are_points_compressed: ', laz.header.are_points_compressed)print('offset: ', laz.header.offsets)print('scale: ', laz.header.scales)print('min: ', laz.header.mins)print('max: ', laz.header.maxs)print('-------\n')print(laz.point_format.dimension_names)print('laz.x: ', laz.x)print('laz.y: ', laz.y)print('laz.z: ', laz.z)print('laz.intensity: ', laz.intensity)print('laz.gps_time: ', laz.gps_time)print('laz.points: ', laz.points)print('laz.points_data: ', laz.points_data)print(laz.points_data.point_format.id)print(laz.points_data.array)print(laz.points_data.point_size)def main():lazread('E:/Las/1001217_las2laz.laz')print('-------------endl-----------')if __name__ == "__main__":main()

以上测试均在windows10中进行,都ok
centos服务器上 方式2中读取laz方式的可以支持;方式3中的不支持,报错如下:

raise ValueError(“Unable to read compressed file!”) ValueError: Unable to read compressed file!

python 点云las、laz文件的读取、写入、压缩相关推荐

  1. python怎么读写文件-一文看懂Python文件的读取写入操作,建议收藏-bak文件怎么打开...

    文件的读取写入操作 读取文件read() 假设我们有一个与操作文件同级的1.txt文档with open('pi_digits.txt') as file_object: contents = fil ...

  2. php csv文件的读取,写入,输出下载操作详解

    2019独角兽企业重金招聘Python工程师标准>>> php对csv文件的读取,写入,输出下载操作. 代码: <?php $file = fopen('text.csv',' ...

  3. java 读取dwg_jdwglib java dwg文件的读取,写入开发包. dwg使用当前 常方便,测试代码和jar都有 CAD 247万源代码下载- www.pudn.com...

    文件名称: jdwglib下载  收藏√  [ 5  4  3  2  1 ] 所属分类: CAD 开发工具: Java 文件大小: 608 KB 上传时间: 2015-12-08 下载次数: 0 提 ...

  4. C#中File类中文件的读取写入

    C#中File类中文件的读取写入 注意:使用File读取写入文件非常简单,但FIle的操作方式决定只能读取小文件,读写时全部加载进行读取.读写大文件时建议使用文件流. 常用方法 //获取所有编码方式 ...

  5. lasTools laszip.exe 点云las/laz的无损压缩/解压缩工具

    laszip 以完全无损的压缩.解压缩存储在二进制文件las/laz中的lidar点云数据,支持las(1.0-1.4)规格. 查看点云规格可参考 该工具带有LGPL许可证.LasTools使用的 L ...

  6. python输入文件名读取文件_[Python] python3 文件操作:从键盘输入、打开关闭文件、读取写入文件、重命名与删除文件等...

    1.从键盘输入 Python 2有两个内置的函数用于从标准输入读取数据,默认情况下来自键盘.这两个函数分别是:input()和raw_input(). Python 3中,不建议使用raw_input ...

  7. Python文件操作-文本文件、二进制文件、csv文件的读取写入、OS、shutil、CSV模块、常用字符编码

    Python文件操作 文本文件和二进制文件 文件操作相关模块 open()创建文件对象 文件对象的常用属性和方法 pickle 序列化 文本文件读取和写入 文本文件写入步骤 write()/write ...

  8. Python 文件打开读取写入方法

    目录 前言 open()方法 with open()方法 实用案例 前言 读写文件是最常见的IO操作.Python内置了读写文件的函数,用法和C是兼容的. 读写文件前,我们先必须了解一下,在磁盘上读写 ...

  9. 【Python基础】生成.pkl文件,读取.pkl文件的内容

    保存 def save_dict(data, name):with open(name + '.pkl', 'wb') as f:pickle.dump(data, f, pickle.HIGHEST ...

  10. java压缩文件读取_用Java读取/写入压缩和非压缩文件

    java压缩文件读取 这篇文章的主要原因是尝试不要重复自己( DRY ),因为通常,我会遇到递归的需求,即读写压缩的和非压缩的文件(主要是JSON和CSV). 首先让我们看看如何读取文本文件. 注意我 ...

最新文章

  1. python threading 多线程
  2. Javascript简单教程汇总
  3. php_DBHelper
  4. Excel 公式(细节若干)
  5. hdu1010深搜+奇偶剪枝
  6. 飞利浦dicom_如何按计划打开或关闭飞利浦色相灯
  7. java程序员经常使用的Intellij Idea插件
  8. 39个必知必会的SQL 性能调优方法
  9. 全员5G!iPhone 12系列终于来了:没有阉割,售价依旧5499元起!
  10. 探地雷达系统行业调研报告 - 市场现状分析与发展前景预测
  11. 当最有创意的开发者遇上移动云,谁将成为创新之王?
  12. C++中list的各种使用
  13. .NET报表控件ActiveReports 教程:应用系统中如何完成各种报表系统的需求
  14. 二叉平衡树AVL简介
  15. 重构kz-admin
  16. PGM学习之四 Factor,Reasoning
  17. 数据结构:假设有一个带头结点的单链表L,每个结点值由单个数字、小写字母和大写字母构成。设计一个算法将其拆分成3个带头结点的单链表L1、L2和L3,L1包含L中的所有数字结点,L2包含L中的所有小写字母
  18. iphone手机音频AAC视频H264推流(一) iphone手机推流最佳方案
  19. HTML5期末大作业:婚庆网站设计——红色的婚庆(18页) HTML5网页设计成品_学生DW静态网页设计代做_web课程设计网页制作
  20. 矩阵分析之Householder Reduction

热门文章

  1. 2021年大数据ELK(二十七):数据可视化(Visualize)
  2. 2021年大数据Kafka(四):❤️kafka的shell命令使用❤️
  3. OpenResty搭建高性能服务端
  4. linux文件移出目录命令_Linux 文件与目录管理详解
  5. python 2x xlrd使用merged_cells 读取的合并单元格为空
  6. 设计模式之创建型汇总
  7. Android 支付宝H5 没有回调
  8. Go 学习笔记(32)— 类型系统(命名类型、未命名类型、底层类型、类型强制转换、类型别名和新声明类型)
  9. MySQL 单表优化
  10. vue.js安装过程(npm安装)