我正在尝试使用PDAL的Python扩展来读取laz文件。
为此,我使用的是以下示例中的简单管道结构:https://gis.stackexchange.com/questions/303334/accessing-raw-data-from-laz-file-in-python-with-open-source-software。但是,对“ filename:”字段的变量插入包含的值对我来说将很有用。为此,我尝试了以下操作,其中fullFileName是包含文件名(完整路径)的str变量,但是却收到一个错误消息,指出该文件不存在。我以为我的JSON语法稍微有些偏离;有人可以帮忙吗?
pipeline="""{
"pipeline": [
{
"type": "readers.las",
"filename": "{fullFileName}"
}
]
}"""
答案 0 :(得分:0)
您可以遵循以下代码:
import json
import pdal
file = "D:/Lidar data/input.laz"
pipeline={
"pipeline": [
{
"type": "readers.las",
"filename": file
},
{
"type": "filters.sort",
"dimension": "Z"
}
]
}
r = pdal.Pipeline(json.dumps(pipeline))
r.validate()
points = r.execute()
print(points)