Perfect answer by @andre-silva but let met add few informations. In lidR 1.5.0
you will be able to clip using a SpatialPolygonDataFrame
. In that case you will get a list
of LAS objects (one per polygon).
las = catalog("file.las")
spdf <- readOGR(dsn = "...", layer = "...")
clipped_las = lasclip(ctg, spdf)
Also lasclip
will be compatible with a LAScatalog
. You don't need anymore to load the entire tile to extract a single polygon. Just extract the polygon.
ctg = catalog("directory/")
spdf <- readOGR(dsn = "...", layer = "...")
poly <- spdf@polygons[[1]]@Polygons[[1]] # sp object of class Polygon
clipped_las = lasclip(ctg, poly)
But be careful. You can't clip a SpatialPolygonDataFrame
from a LAScatalog
. If it is technically possible it has been disabled for memory safety reasons. Indeed, assume you have 1000 tiles over 1000 km² and a shapefile with hundreds of large polygons, this would load too much data.In order to prevent R crash with bad usage this option is disabled.