Edit: The package is evolving. As stated in JRR's answer which is one of lidR
's authors, newer versions (> 1.5) will support clipping with SpatialPolygonDataFrame
. It is also planned to support clipping with multipart polygons.
The package ‘lidR’ (version 1.4.2*) pdf says on lasclip
:
Usage:
lasclip(x, geometry, ofile = "")
Arguments
geometry: a geometric object. Currently* Polygon from sp is supported.
*apr/2018
Therefore, one needs to clip the .las/.laz data with an object of class Polygon
and not SpatialPolygonsDataFrame
.
This is a reproducible example which works:
library(lidR)
file.path <- system.file("extdata", "Megaplot.laz", package="lidR")
lidar <- readLAS(file.path)
library(rgdal)
site_spdf <- readOGR(dsn = "...lidR\\extdata", layer = "lake_polygons_UTM17")
site_p <- site_spdf@polygons[[1]]@Polygons[[1]] #sp object of class Polygon
clipped_las = lasclip(lidar, site_p)
Other software options for clipping LiDAR files with vector data are available in Clipping LAS data using shapefile polygons and open source software?