import adaptivefiltering as af
adaptivefiltering
stores filter pipelines in .json
files for later reuse. JSON stands for JavaScript Object Notation and is a widely used format for storing custom data structures. We will see in Creating filter pipelines how these files are created from scratch. Now, we will learn how to use these files. This will enable you to leverage a library of community-contributed filter pipelines and allow you to organize your filter pipelines locally.
Filter libraries are directories that contain a number of .json
files that contain filter pipeline definitions. adaptivefiltering
internally keeps a per-session list of known filter libraries which by default contains the current working directory and the path to the library of community-contributed filters, which has been installed as a separate Python package. We can manually register directories as filter libraries like this:
af.add_filter_library(path="/home/user/somepath", recursive=False)
The recursive
parameter specifies whether filter pipelines in subdirectories of the given directory should also be taken into account (defaults to False
).
We can search our filter libraries for filter pipelines matching certain criteria by using the select_pipeline_from_library
and select_pipelines_from_library
functions. The former will allow you to select exactly one pipeline, where as the latter allows you to select multiple pipelines by holding CTRL
pressed while clicking on the filters. Clicking the Finalize button will make the user interface vanish, but you can also use the returned pipeline
object before that:
pipeline = af.select_pipeline_from_library()
In the left most column, we see filtering criterions we can use to access the filter pipelines in our filtering libraries. The middle column contains a list of filter pipelines that match the given criteria. Clicking one of these will select it and show its metadata in the third column. The returned pipeline
object can then be passed to other functions adaptivefiltering
, e.g. to select the best filter pipeline for a given dataset.
adaptivefiltering
does not implement its own ground point filtering algorithms. Instead, algorithms from existing packages are accessible through a common interface. Currently, the following backends are available:
lasground_new
that can be used for ground point filtering.PDAL is always available when using adaptivefiltering
and is used internally for many tasks that are not directly related to ground point filtering. In order to enable the OPALS backend, adaptivefiltering
needs to be given the information where your OPALS installation (potentially including your license key) is located. This can either be done by setting the environment variable OPALS_DIR
or by setting the path at runtime:
af.set_opals_directory("/path/to/opals")
Similarly, you can set the path to your installation of LASTools either through the environment variable LASTOOLS_DIR
or at runtime:
af.set_lastools_directory("/path/to/lastools")
Please note that LASTools only ships Windows binaries. Therefore, you will need Wine installed on your system to successfully use the LASTools backend on Linux.
As filter libraries are just directories on the file system, you are free to organizing them yourself by moving and copying files and then making the respective directories known to adaptivefiltering
using add_filter_library
as seen above. However, there is also additional functionality available that eases the management process. If you are editing filter pipelines a lot, you might want to set the current library path like this:
af.set_current_filter_library("mylibrary", create_dirs=True, name="My testing library")
The library defined by set_current_filter_library
will be used as the default path to store filter pipelines using save_filter or select_best_pipeline. Here, the name
parameter is used to define a display name for the filter library. It is stored in JSON file called library.json
in the directory. Such file could also be added manually to filter library directories. If you do not want to generate library.json
or do not want to override an existing one, you may set name=None
.
As each filter pipeline is stored as a separate file, filter pipelines can be shared easily by sharing these files via your favorite method. If you want to share your filter pipeline with a wider community, you should consider contributing it to adaptivefiltering
's community contribution library. This will make your filter pipeline accessible to all useres of adaptivefiltering
. You can find the details of the process on GitHub.
If, for some reason, you want to reset the currently registered filter libraries to the default ones, you can do so like this:
af.reset_filter_libraries()