pyfor.ground_filter module

class pyfor.ground_filter.GroundFilter

Bases: object

class pyfor.ground_filter.KrausPfeifer1998(cell_size, a=1, b=4, g=-2, w=2.5, iterations=5, tolerance=0)

Bases: object

Holds functions and data for implementing Kraus and Pfeifer (1998) ground filter. The Kraus and Pfeifer ground filter is a simple filter that uses interpolation of errors and an iteratively constructed surface to filter ground points. This filter is used in FUSION software, and the same default values for the parameters are used in this implementation.

__init__(cell_size, a=1, b=4, g=-2, w=2.5, iterations=5, tolerance=0)
Parameters
  • cell_size – The cell size of the intermediate surface used in filtering in the same units as the input cloud. Values from 1 to 40 are common, depending on the units in which the original point cloud is projected.

  • a – A steepness parameter for the interpolating function.

  • b – A steepness parameter for the interpolating function.

  • g – The distance from the surface under which all points are given a weight of 1.

  • w – The window width from g up considered for weighting.

  • iterations – The number of iterations, i.e. the number of surfaces constructed.

bem(cloud, cell_size)

Retrieve the bare earth model (BEM).

Parameters
  • cloud – A cloud object.

  • cell_size – The cell size of the BEM, this is independent of the cell size used in the intermediate surfaces.

Returns

A Raster object that represents the bare earth model.

classify(cloud, ground_int=2)

Sets the classification of the original input cloud points to ground (default 2 as per las specification). This performs the adjustment of the input Cloud object in place. Only implemented for .las files. Additionally, the original ground classification is preserved if it exists, so this will only add additional ground points for already classified point clouds.

Parameters
  • cloud – A cloud object.

  • ground_int – The integer to set classified points to, the default is 2 in the las specification for ground

points.

ground_points(cloud)

Returns a new Cloud object that only contains the ground points. :return:

normalize(pc, cell_size)

Normalizes the original point cloud in place. This creates a BEM as an intermediate product, please see .bem() to return this directly.

Parameters
  • pc – A cloud object.

  • cell_size – The cell_size for the intermediate BEM. Values from 1 to 6 are common.

class pyfor.ground_filter.Zhang2003(cell_size, n_windows=5, dh_max=2, dh_0=1, b=2, interp_method='nearest')

Bases: object

Implements Zhang et. al (2003), a progressive morphological ground filter. This filter uses an opening operation combined with progressively larger filtering windows to remove features that are ‘too steep’. This particular implementation interacts only with a raster, so the output resolution will be dictated by the cell_size argument.

__init__(cell_size, n_windows=5, dh_max=2, dh_0=1, b=2, interp_method='nearest')
Parameters
  • cloud – The input cloud object.

  • n_windows – The number of windows to construct for filtering.

  • dh_max – The maximum height threshold.

  • dh_0 – The starting null height threshold.

  • cell_size – The cell_size used to construct the array for filtering, also the output size of the BEM.

  • interp_method – The interpolation method used to fill nan values in the final BEM.

bem(cloud, classified=False)

Retrieve the bare earth model (BEM). Unlike KrausPfeifer1998, the cell size is defined upon initialization of the filter, and thus it is not required to retrieve the bare earth model from the filter.

Parameters

cloud – A Cloud object.

Returns

A Raster object that represents the bare earth model.

normalize(cloud)

Normalizes the original point cloud in place. This creates a BEM as an intermediate product, please see .bem() to return this directly.

Parameters

cloud – The input cloud object to normalize.