The Local Maximum stage identifies points that are locally maximum. The window size is
fixed and circular. This stage does not modify the point cloud. It produces a derived product
in vector format. The function local_maximum_raster
applies on a raster instead of the point cloud
Arguments
- ws
numeric. Diameter of the moving window used to detect the local maxima in the units of the input data (usually meters).
- min_height
numeric. Minimum height of a local maximum. Threshold below which a point cannot be a local maximum. Default is 2.
- filter
the 'filter' argument allows filtering of the point-cloud to work with points of interest. The available filters are those from LASlib and can be found by running filter_usage. For a given stage when a filter is applied, only the points that meet the criteria are processed. The most common strings are "-keep_first", "-keep_class 2", "drop_z_below 2". For more details see filters.
- ofile
character. Full outputs are always stored on disk. If
ofile = ""
then the stage will not store the result on disk and will return nothing. It will however hold partial output results temporarily in memory. This is useful for stage that are only intermediate stage.- use_attribute
character. By default the local maximum is performed on the coordinate Z. Can also be the name of an extra bytes attribute such as 'HAG' if it exists. Can also be 'Intensity' but there is probably no use case for that one.
- record_attributes
The coordinates XYZ of points corresponding to the local maxima are recorded. It is also possible to record the attributes of theses points such as the intensity, return number, scan angle and so on.
- raster
LASRalgorithm. A stage that produces a raster.
Value
This stage produces a vector. The path provided to `ofile` is expected to be `.gpkg` or any other format supported by GDAL. Vector stages may produce geometries with Z coordinates. Thus, it is discouraged to store them in formats with no 3D support, such as shapefiles.
Examples
f <- system.file("extdata", "MixedConifer.las", package = "lasR")
read <- reader_las()
lmf <- local_maximum(5)
ans <- exec(read + lmf, on = f)
ans
#> Simple feature collection with 177 features and 0 fields
#> Geometry type: POINT
#> Dimension: XYZ
#> Bounding box: xmin: 481260 ymin: 3812921 xmax: 481349.8 ymax: 3813011
#> z_range: zmin: 2.42 zmax: 32.07
#> Projected CRS: NAD83 / UTM zone 12N
#> # A tibble: 177 × 1
#> geom
#> <POINT [m]>
#> 1 Z (481309.9 3812944 22.55)
#> 2 Z (481294.7 3813011 16)
#> 3 Z (481307.2 3813000 27.09)
#> 4 Z (481281.9 3813003 26.95)
#> 5 Z (481278.4 3813002 23.58)
#> 6 Z (481302.9 3812929 25.65)
#> 7 Z (481265.3 3812996 19.75)
#> 8 Z (481302.9 3812969 22.97)
#> 9 Z (481261.8 3812999 18.89)
#> 10 Z (481302 3812947 18.58)
#> # ℹ 167 more rows
chm <- rasterize(1, "max")
lmf <- local_maximum_raster(chm, 5)
ans <- exec(read + chm + lmf, on = f)
# terra::plot(ans$rasterize)
# plot(ans$local_maximum, add = T, pch = 19)