R: Classify points of interest

classify_poi {lidR} | R Documentation

## Classify points of interest

### Description

Classify points that meet some logical criterion and/or that belong in a region of interest. The function updates the attribute `Classification` of the LAS object.

### Usage

    classify_poi(
      las,
      class,
      poi = NULL,
      roi = NULL,
      inverse_roi = FALSE,
      by_reference = FALSE,
      ...
    )

### Arguments

`las` | An object of class LAS or LAScatalog.
`class` | The ASPRS class to attribute to the points that meet the criterion.
`poi` | a formula of logical predicates. The points that are `TRUE` will be classified `class`.
`roi` | A `SpatialPolygons`, `SpatialPolygonDataFrame` from `sp` or a `POLYGON` from `sf`. The points that are in the region of interest delimited by the polygon(s) are classified `class`.
`inverse_roi` | bool. Inverses the `roi`. The points that are outside the polygon(s) are classified `class`
`by_reference` | bool. Updates the classification in place (LAS only).
`...` | Unused

### Value

If the input is a `LAS` object, return a `LAS` object. If the input is a `LAScatalog`, returns a `LAScatalog`.

### Working with a `LAScatalog`

This section appears in each function that supports a LAScatalog as input.

In `lidR` when the input of a function is a LAScatalog the function uses the LAScatalog processing engine. The user can modify the engine options using the available options. A careful reading of the engine documentation is recommended before processing `LAScatalogs`. Each `lidR` function should come with a section that documents the supported engine options.

The `LAScatalog` engine supports `.lax` files that significantly improve the computation speed of spatial queries using a spatial index. Users should really take advantage a `.lax` files, but this is not mandatory.

### Supported processing options

Supported processing options for a `LAScatalog` (in bold). For more details see the LAScatalog engine documentation:

- chunk size: How much data is loaded at once.

- chunk buffer: A buffer is not need for this function to works thus `buffer = 0` and cannot be changed.

- chunk alignment: Align the processed chunks.

- progress: Displays a progression estimation.

- output files*: Mandatory because the output is likely to be too big to be returned in R and needs to be written in las/laz files. Supported templates are `{XLEFT}`, `{XRIGHT}`, `{YBOTTOM}`, `{YTOP}`, `{XCENTER}`, `{YCENTER}` `{ID}` and, if chunk size is equal to 0 (processing by file), `{ORIGINALFILENAME}`.

- select: The function will write files equivalent to the original ones. Thus `select = "*"` and cannot be changed.

- filter: Read only points of interest.

### Examples

    LASfile <- system.file("extdata", "Megaplot.laz", package="lidR")
    shp     <- system.file("extdata", "lake_polygons_UTM17.shp", package = "lidR")

    las  <- readLAS(LASfile, filter = "-keep_random_fraction 0.1")
    lake <- sf::st_read(shp, quiet = TRUE)

    # Classifies the points that are NOT in the lake and that are NOT ground points as class 5
    poi <- ~Classification != LASGROUND
    las <- classify_poi(las, LASHIGHVEGETATION, poi = poi, roi = lake, inverse = TRUE)

    # Classifies the points that are in the lake as class 9
    las <- classify_poi(las, LASWATER, roi = lake, inverse = FALSE)

    #plot(las, color = "Classification")

[Package lidR version 3.2.2 Index]