PDAL / python

PDAL's Python Support
Other
116 stars 34 forks source link

Get error when trying to use filters.hag_delaunay? #118

Closed norrila closed 2 years ago

norrila commented 2 years ago

I am trying to use this Python code to do a hag delaunay filter:

pipeline = pdal.Reader("D:\input.las" | pdal.Filter.hag_delaunay)
count = pipeline.execute()

But I get the following error I get in console: TypeError: unsupported operand type(s) for |: 'str' and 'function'

I have no issues when using:

pipeline = pdal.Reader('d:input_las.las')
count = pipeline.execute()

So I assume its the pdal.Filter.hag_delaunay that is causing issues.

What is the naming convention for any filters that have an underscore in the name such as all the filters in the height above ground category? https://pdal.io/stages/filters.html#height-above-ground

Also, is there a description/list of the syntax for all the PDAL functions? for example in the PDAL documentation its filters.sort while in PDAL Python its Filter.sort. I find this difference in syntax really difficult to know the exact syntax for a function.

gsakkis commented 2 years ago

pipeline = pdal.Reader("D:\input.las" | pdal.Filter.hag_delaunay)

This should be: pipeline = pdal.Reader("D:\input.las") | pdal.Filter.hag_delaunay()

What is the naming convention for any filters that have an underscore in the name such as all the filters in the height above ground category?

It's identical, underscores are preserved. By the way you can experiment interactively in a Jupyter notebook or IPython shell, just hit tab after pdal.Filter.hag and you'll get an dropdown list of all filters with this prefix.

Untitled-Jupyter-Notebook

Also, is there a description/list of the syntax for all the PDAL functions? for example in the PDAL documentation its filters.sort while in PDAL Python its Filter.sort.

The mapping is straightforward:

norrila commented 2 years ago

Thank you so much for the quick reply and detailed answer!!

The solution worked as expected and the examples cleared some other issues I was having (such as the proper use of pdal.Filter.hag_delaunay() instead of pdal.Filter.hag_delaunay which I was trying.

I am new to Python, so the Jupyter tips are really appreciated.