# lasclip

0th

Percentile

##### Clip LiDAR points

Clip LiDAR points within a given geometry from a point cloud (LAS object) or a catalog (LAScatalog object). With a LAS object, the user first reads and loads a point-cloud into memory and then can clip it to get a subset within a region of interest (ROI). With a LAScatalog object, the user can extract any arbitrary ROI for a set of las/laz files, loading only the points of interest. This is faster, easier and much more memory-efficient for extracting ROIs.

##### Usage
lasclip(las, geometry, ...)lasclipRectangle(las, xleft, ybottom, xright, ytop)lasclipPolygon(las, xpoly, ypoly)lasclipCircle(las, xcenter, ycenter, radius)
##### Arguments
las

An object of class LAS or LAScatalog.

geometry

a geometric object. Many types are supported, see section 'supported geometries'.

...

optional supplementary options (see supported geometries)

xleft

numeric. left x coordinates of rectangles.

ybottom

numeric. bottom y coordinates of rectangles.

xright

numeric. right x coordinates of rectangles.

ytop

numeric. top y coordinates of rectangles.

xpoly

numeric. x coordinates of a polygon.

ypoly

numeric. y coordinates of a polygon.

xcenter

numeric. x coordinates of discs centers.

ycenter

numeric. y coordinates of discs centers.

radius

numeric. disc radius or radii.

##### Value

If the input is a LAS object: an object of class LAS, or a list of LAS objects if the query implies several regions of interest will be returned. If the input is a LAScatalog object: an object of class LAS, or a list of LAS objects if the query implies several regions of interest will be returned, or a LAScatalog if the queries are immediately written into files without loading anything in R.

##### Supported geometries

• WKT string: describing a POINT, a POLYGON or a MULTIPOLYGON.

• SpatialPoints or SpatialPointsDataFrame in that case a parameter 'radius' must be passed in '...'

• SimpleFeature that consistently contains POINT or POLYGON/MULTIPOLYGON. In case of POINT a parameter 'radius' must be passed in '...'

• Extent

• matrix 2 x 2 describing a bounding box following this order:

  min     max
x 684816  684943
y 5017823 5017957

##### 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: Does not make sense here.

• buffer: Not supported yet.

• alignment: Does not makes sense here.

• cores: How many cores are used.

• progress: Displays a progress estimation.

• stop_early: Leave this 'as-is' unless you are an advanced user.

• output_files: If 'output_files' is set in the catalog, the ROIs will not be returned in R. They will be written immediately in files. See LAScatalog-class and examples. The allowed templates in lasclip are {XLEFT}, {XRIGHT}, {YBOTTOM}, {YTOP}, {ID}, {XCENTER}, {YCENTER} or any names from the table of attributes of a spatial object given as input such as {PLOT_ID} or {YEAR}, for example, if these attributes exist. If empty everything is returned into R.

• laz_compression: write las or laz files

• drivers: Leave this 'as-is' unless you are an advanced user.

• select: The function will write files equivalent to the originals. This option is not respected.

• filter: Read only the points of interest.

##### Aliases
• lasclip
• lasclipRectangle
• lasclipPolygon
• lasclipCircle
##### Examples
# NOT RUN {
LASfile <- system.file("extdata", "Megaplot.laz", package="lidR")

# Load the file and clip the region of interest
las = readLAS(LASfile)
subset1 = lasclipRectangle(las, 684850, 5017850, 684900, 5017900)

# Do not load the file(s), extract only the region of interest from a bigger dataset
ctg = catalog(LASfile)
subset2 = lasclipRectangle(ctg, 684850, 5017850, 684900, 5017900)

# Extract all the polygons from a shapefile
shapefile_dir <- system.file("extdata", package = "lidR")
lakes = shapefile(paste0(shapefile_dir, "/lake_polygons_UTM17.shp"))
subset3 = lasclip(ctg, lakes)

# Extract the polygons, write them in files named after the lake names, do not load anything in R
opt_output_files(ctg) <- paste0(tempfile(), "_{LAKENAME_1}")
new_ctg = lasclip(ctg, lakes)

# }
# NOT RUN {
plot(subset1)
plot(subset2)
plot(subset3)
# }

Documentation reproduced from package lidR, version 2.0.0, License: GPL-3

### Community examples

Looks like there are no examples yet.