pyfor.collection module

class pyfor.collection.CloudDataFrame(*args, **kwargs)

Bases: geopandas.geodataframe.GeoDataFrame

Implements a data frame structure for processing and managing multiple Cloud objects. It is recommended to initialize using the from_dir() function.

__init__(*args, **kwargs)

Initialize self. See help(type(self)) for accurate signature.

property bounding_box
Returns

A tuple (minx, miny, maxx, maxy) of the bounding box for the entire collection.

create_index()

For each file in the collection, creates .lax files for spatial indexing using the default values.

property indexed
Returns

True if all files have an equivalent .lax present, otherwise False.

map_poly(las_path, polygon)
par_apply(func, indexed=True, by_file=False)

Apply a function to the collection in parallel. There are two major use cases:

1. Buffered Tiles: In the case of buffered tiles, the func argument should contain a function that takes two arguments, the first being an aggregated cloud.Cloud object, and the second being a shapely.geometry.Polygon that describes the bounding box of the aggregated tile. For this case, set by_file to False (this is the default).

2. Raw Files: In the case of processing raw tiles in parallel, the func argument should contain a function that takes only one argument, the absolute file path to the tile at that iteration. For this case, set by_file to True.

Parameters
  • func – A function used to process each tile or raw file (see above).

  • indexed – Determines if .lax files will be leveraged to reduce memory consumption.

  • by_file – Forces par_apply to operate on raw files only if True.

plot(**kwargs)

Plots the bounding boxes of the Cloud objects.

Parameters

**kwargs

Keyword arguments to geopandas.GeoDataFrame.plot().

plot_metrics(heightbreak, index=None)

Retrieves a set of 29 standard metrics, including height percentiles and other summaries. Intended for use on plot-level point clouds. :param index: An iterable of indices to set as the output dataframe index. :return: A pandas dataframe of standard metrics.

reset_tiles()

Reset the tiles to describe the bounding boxes of each .las file in place.

retile_raster(cell_size, target_tile_size, buffer=0)

A retiling operation that creates raster-compatible sized tiles. Important for creating project-level rasters. Changes self.tiles in place. Note that the target tile size is approximate, and is rounded to the neareast size that is compatible with the defined cell size.

Parameters
  • cell_size – The target cell size of the output raster.

  • target_tile_size – The target tile size of the retiling operation.

  • buffer – The amount to buffer each input tile.

class pyfor.collection.Retiler(cdf)

Bases: object

__init__(cdf)

Retiles a CloudDataFrame. Generally used to create tiles such that rasters generated from tiles are properly aligned.

retile_buffer(buffer)

A simple buffering operation.

Returns

A list of buffered shapely polygons.

retile_raster(target_cell_size, original_tile_size, buffer=0)

Creates a retiling grid for a specified target cell size. This creates a list of polygons such that if a raster is constructed from a polygon it will exactly fit inside given the specified target cell size. Useful for creating project level rasters.

Parameters
  • target_cell_size – The desired output cell size

  • original_tile_size – The original tile size of the project

  • buffer – The distance to buffer each new tile to prevent edge effects.

Returns

A list of shapely polygons that correspond to the new grid.

pyfor.collection.from_dir(las_dir, **kwargs)

Constructs a CloudDataFrame from a directory of las files.

Parameters
  • las_dir – The directory of las or .laz files.

  • glob_str – A glob string to select files from the directory. For example: “*.laz” to select .laz files only.

Returns

A CloudDataFrame constructed from the directory of las files.