pyfor.cloud module¶
-
class
pyfor.cloud.
Cloud
(path)¶ Bases:
object
The cloud object is an API for interacting with .las, .laz, and .ply files in memory, and is generally the starting point for any analysis with pyfor. For a more qualitative assessment of getting started with
Cloud
please see the user manual.-
__init__
(path)¶ Initialize self. See help(type(self)) for accurate signature.
-
chm
(cell_size, interp_method=None, pit_filter=None, kernel_size=3)¶ Returns a
Raster
object of the maximum z value in each cell, with optional interpolation (i.e. nan-filling) and pit filter parameters. Currently, only a median pit filter is implemented.- Parameters
cell_size – The cell size for the returned raster in the same units as the parent Cloud or las file.
interp_method – The interpolation method as a string to fill in NA values of the produced canopy height model, one of either “nearest”, “cubic”, or “linear”. This is an argument to scipy.interpolate.griddata.
pit_filter – If “median” passes a median filter over the produced canopy height model.
kernel_size – The kernel size of the median filter, must be an odd integer.
- Returns
A
Raster
object of the canopy height model.
-
clip
(polygon)¶ Clips the point cloud to the provided shapely polygon using a ray casting algorithm. This method calls
clip.poly_clip()
directly. This returns a newCloud
.- Parameters
polygon – A
shapely.geometry.Polygon
in the same CRS as the Cloud.- Returns
A new :class:.`Cloud` object clipped to the provided polygon.
-
property
convex_hull
¶ Calculates the convex hull of the cloud projected onto a 2d plane, a wrapper for
scipy.spatial.ConvexHull()
.- Returns
A
shapely.geometry.Polygon
of the convex hull.
-
filter
(min, max, dim)¶ Filters a cloud object for a given dimension in place.
- Parameters
min – Minimum dimension to retain.
max – Maximum dimension to retain.
dim – The dimension of interest as a string. For example “z”. This corresponds to a column label in
self.data.points
.
-
classmethod
from_pdal
(ins)¶ Converts a PDAL ins argument from a PDAL filters.python into a Cloud object.
- Parameters
ins – The ins argument from PDAL.
-
grid
(cell_size)¶ Generates a
Grid
object for the parent object given a cell size. See the documentation forGrid
for more information.- Parameters
cell_size – The resolution of the plot in the same units as the input file.
- Returns
A
Grid
object.
-
normalize
(cell_size, classified=False, **kwargs)¶ Normalize the cloud using the default Zhang et al. (2003) progressive morphological ground filter. Please see the documentation in
ground_filter.Zhang2003
for more information and keyword argument definitions. If you want to use a pre-computed DEM to normalize, please seesubtract()
.- Parameters
cell_size – The resolution of the intermediate bare earth model.
classified – If True and file type is .las or .laz, uses the points classified as ground (i.e. 2) to construct the intermediate bare earth model.
-
plot
(cell_size=1, cmap='viridis', return_plot=False, block=False)¶ Plots a basic canopy height model of the Cloud object. This is mainly a convenience function for
Raster.plot
. More robust methods exist for dealing with canopy height models. Please see the user manual.- Parameters
clip_size – The resolution of the plot in the same units as the input file.
return_plot – If true, returns a matplotlib plt object.
- Returns
If return_plot == True, returns matplotlib plt object. Not yet implemented.
-
plot3d
(dim='z', point_size=1, cmap='Spectral_r', max_points=500000.0, n_bin=8, plot_trees=False)¶ Plots the three dimensional point cloud using a Qt backend. By default, if the point cloud exceeds 5e5 points, then it is downsampled using a uniform random distribution. This is for performance purposes.
- Parameters
point_size – The size of the rendered points.
dim – The dimension upon which to color (i.e. “z”, “intensity”, etc.)
cmap – The matplotlib color map used to color the height distribution.
max_points – The maximum number of points to render.
-
standard_metrics
(heightbreak=0)¶
-
subtract
(path)¶ Normalize using a pre-computed raster file, i.e. “subtract” the heights from the input raster in place. This assumes the raster and the point cloud are in the same coordinate system. :param path: The path to the raster file, must be in a format supported by rasterio. :return:
-
write
(path)¶ Write to file. The precise mechanisms of this writing will depend on the file input type. For .las files this will be handled by
LASData.write()
, for .ply files this will be handled byPLYData.write()
.- Parameters
path – The path of the output file.
-
-
class
pyfor.cloud.
CloudData
(points, header)¶ Bases:
object
-
__init__
(points, header)¶ Initialize self. See help(type(self)) for accurate signature.
-
-
class
pyfor.cloud.
LASData
(points, header)¶ Bases:
pyfor.cloud.CloudData
-
write
(path)¶ Writes the object to file. This is a wrapper for
laspy.file.File()
- Parameters
path – The path of the ouput file.
-
-
class
pyfor.cloud.
PLYData
(points, header)¶ Bases:
pyfor.cloud.CloudData
-
write
(path)¶ Writes the object to file. This is a wrapper for
plyfile.PlyData.write()
- Parameters
path – The path of the ouput file.
-