lasclassify
Classify LiDAR points from source data
Classify LAS points based on geographic data from external sources. It adds an attribute to each point based on a value found in the external data. External sources can be an ESRI Shapefile (SpatialPolygonsDataFrame) or a Raster (RasterLayer).
Usage
lasclassify(.las, source, field = NULL)
Arguments
- .las
An object of the class
LAS
- source
An object of class
SpatialPolygonsDataFrame
orRasterLayer
- field
characters. The name of a field in the table of attributes of the shapefile or the name of the new column in the LAS object (see details)
Details
The function recognizes several type of sources:
SpatialPolygonsDataFrame
: Polygons can be simple, one-part shapes, multi-part polygons, or polygons with holes. It checks if the LiDAR points are in polygons given in the shapefile. If the parameterfield
is the name of a field in the table of attributes of the shapefile it assigns to the points the values of that field. Otherwise it classifies the points as boolean. TRUE if the points are in a polygon, FALSE otherwise. This function allows filtering of lakes, for example.RasterLayer
: It attributes to each point the value found in each pixel of the RasterLayer. Use the parameterfield
to force the name of the new column added in the LAS object. This function is used internally to normalize the lidar dataset and is exported because some users may find it useful (for example to colorize the point cloud using a georeferenced RGB image.
More examples available on lidR wiki.
Value
Nothing. The new field is added by reference to the original data.
See Also
Examples
# NOT RUN {
LASfile <- system.file("extdata", "Megaplot.laz", package="lidR")
shapefile_dir <- system.file("extdata", package = "lidR")
lidar = readLAS(LASfile)
lakes = rgdal::readOGR(shapefile_dir, "lake_polygons_UTM17")
# The field "inlake" does not exist in the shapefile. Points are classified as TRUE if in a polygon
lasclassify(lidar, lakes, "inlakes") # New column 'inlakes' is added.
forest = lasfilter(lidar, inlakes == FALSE)
plot(lidar)
plot(forest)
# The field "LAKENAME_1" exists in the shapefile.
# Points are classified with the values of the polygons
lasclassify(lidar, lakes, "LAKENAME_1") # New column 'LAKENAME_1' is added.
# }