API Reference¶
Classification¶
- class laserfarm.Classification(input_file=None, label=None)[source]¶
Bases:
PipelineRemoteDataClassify points using polygons provided as shapefiles.
- classification(ground_type)[source]¶
Classify the pointset according to the given shape file. A new feature “ground_type” will be added to the point cloud. The value of the column identify the ground type.
- Parameters:
ground_type – identifier of the groud type. 0 is not identified.
Retiling¶
- class laserfarm.Retiler(input_file=None, label=None)[source]¶
Bases:
PipelineRemoteDataSplit point cloud data into smaller tiles on a regular grid.
- set_grid(min_x, min_y, max_x, max_y, n_tiles_side)[source]¶
Setup the grid to which the input file is retiled.
- Parameters:
min_x – min x value of tiling schema
min_y – max y value of tiling schema
max_x – min x value of tiling schema
max_y – max y value of tiling schema
n_tiles_side – number of tiles along axis. Tiling MUST be square
(enforced)
Data processing¶
- class laserfarm.DataProcessing(input=None, label=None, tile_index=(None, None))[source]¶
Bases:
PipelineRemoteDataRead, process and write point cloud data using laserchicken.
- add_custom_feature(extractor_name, **parameters)[source]¶
Add customized feature to be computed with laserchicken.
For information on the available extractors and the corresponding :param $ laserfarm data_processing extractors –help: :param $ laserfarm data_processing extractors <extractor_name> –help:
- Parameters:
extractor_name – Name of the (customizable) extractor
parameters – Extractor-specific parameters
- add_custom_features(custom_feature_list)[source]¶
Add a list of customized features to be computed with laserchicken (also see add_custom_feature).
- Parameters:
custom_feature_list – list of extractor names and parameters
- apply_filter(filter_type, **filter_input)[source]¶
Apply a filter to the environment point cloud.
- For information on filter_types and the corresponding input:
$ laserfarm data_processing filter –help $ laserfarm data_processing filter <filter_type> –help
- Parameters:
filter_type – Type of filter to apply.
filter_input – Filter-specific input.
- export_point_cloud(filename='', attributes='all', **export_opts)[source]¶
Write environment point cloud to disk.
- Parameters:
filename – optional filename where to write point-cloud data
attributes – List of attributes to be written in the output file
export_opts – Optional arguments passed to the laserchicken export function
- export_targets(filename='', attributes='all', multi_band_files=True, **export_opts)[source]¶
Write target point cloud to disk.
- Parameters:
filename – optional filename where to write point-cloud data
attributes – List of attributes to be written in the output file
multi_band_files – If true, write all attributes in one file
export_opts – Optional arguments passed to the laserchicken export function
- extract_features(volume_type, volume_size, feature_names, sample_size=None)[source]¶
Extract point-cloud features and assign them to the specified target point cloud.
- Parameters:
volume_type – Type of volume used to construct neighborhoods
volume_size – Size of the volume-related parameter (in m)
feature_names – List of the feature names to be computed
sample_size – Sample neighborhoods with a random subset of points
- property features¶
- generate_targets(min_x, min_y, max_x, max_y, n_tiles_side, tile_mesh_size, validate=True, validate_precision=None)[source]¶
Generate the target point cloud.
- Parameters:
min_x – Min x value of the tiling schema
min_y – Min y value of the tiling schema
max_x – Max x value of the tiling schema
max_y – Max y value of the tiling schema
n_tiles_side – Number of tiles along X and Y (tiling MUST be
square) :param tile_mesh_size: Spacing between target points (in m). The tiles’ width must be an integer times this spacing :param validate: If True, check if all points in the point-cloud belong to the same tile :param validate_precision: Optional precision threshold to determine whether point belong to tile
GeoTIFF export¶
- class laserfarm.GeotiffWriter(input_dir=None, bands=None, label=None)[source]¶
Bases:
PipelineRemoteDataWrite specified bands from point cloud data into separate geotiff files.
- create_subregion_geotiffs(output_handle, EPSG=28992)[source]¶
Export geotiff per sub-region, loop in band dimension
- Parameters:
output_handle – Handle of output file. The output will be named
as <output_handle>_TILE_<tile ID>_BAND_<band name> :param EPSG: (Optional) EPSG code of the spatial reference system of the input data. Default 28992.
Pipeline with remote data¶
- class laserfarm.pipeline_remote_data.PipelineRemoteData[source]¶
Bases:
PipelinePipeline extension to deal with remote input/output
- property input_folder¶
- property input_path¶
- property output_folder¶
- pullremote(remote_origin)[source]¶
pull directory with input file(s) from remote to local fs
- Parameters:
remote_origin – path to directory on remote fs
- pushremote(remote_destination)[source]¶
push directory with output from local fs to remote_dir
- Parameters:
remote_destination – path to remote target directory
- run(pipeline=None)[source]¶
Run the (augmented) pipeline
- Parameters:
pipeline – (optional) Consider the input pipeline if provided
- setup_local_fs(input_folder=None, output_folder=None, tmp_folder='.')[source]¶
IO setup for the local file system.
- Parameters:
input_folder – path to input folder on local filesystem.
output_folder – path to output folder on local filesystem. This folder is considered root for all output paths specified.
tmp_folder – path of the temporary folder, used to set default input and output folders if not specified.
Pipeline¶
- class laserfarm.pipeline.Pipeline[source]¶
Bases:
objectBase Pipeline class to construct workflows. Inheriting classes should define pipeline as the sequence of the methods that constitute the pipeline. After storing the input of the various tasks in the input dictionary, the pipeline can be run with the method run.
Example
>>> class FooBar(Pipeline): ... def __init__(self): ... self.pipeline = ['foo', 'bar'] ... def foo(self, a): ... print(a) ... def bar(self, b): ... print(b) >>> test = FooBar() >>> test.input = {'foo': {'a': 5}, 'bar': {'b': 6}} >>> test.run() 5 6
- config(from_dict=None, from_file=None)[source]¶
Set the pipeline input with a dictionary or by reading a configfile.
- Parameters:
from_dict – Input is given as a dictionary
from_file – Path to the configfile
- property input¶
Dictionary containing the pipeline input. Each attribute entails the input for a pipeline method that needs to be executed.
- label = 'pipeline'¶
- logger = None¶
- property pipeline¶
List containing the consecutive tasks that constitute the pipeline.
Macro Pipeline¶
- class laserfarm.MacroPipeline[source]¶
Bases:
objectClass to setup macro pipeline workflows. Each MacroPipeline object entails multiple tasks that correspond to Pipeline instances. All the tasks are run in parallel using dask.
We implement dask for embarrassingly parallel tasks, see https://examples.dask.org/applications/embarrassingly-parallel.html
Example
>>> class Foo(Pipeline): ... def __init__(self): ... self.pipeline = ['task_info'] ... def task_info(self): ... print(os.getpid()) >>> macro = MacroPipeline() >>> one, two = Foo(), Foo() >>> macro.tasks = [one, two] >>> macro.run() # the default thread parallelism is used 61244 61245
- add_task(task)[source]¶
Add pipeline instance to the collection of tasks to be executed.
- Parameters:
task – Pipeline instance.
- print_outcome(to_file=None)[source]¶
Write outcome of the tasks run. If a file path is not specified, the log outcome is printed to the standard output.
- Parameters:
to_file – file path
- property tasks¶
List of tasks that need to be run.