forked from r-lidar/lidR
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlasclip.Rd
143 lines (116 loc) · 6.05 KB
/
lasclip.Rd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/lasclip.r
\name{lasclip}
\alias{lasclip}
\alias{lasclipRectangle}
\alias{lasclipPolygon}
\alias{lasclipCircle}
\title{Clip LiDAR points}
\usage{
lasclip(las, geometry, ...)
lasclipRectangle(las, xleft, ybottom, xright, ytop, ...)
lasclipPolygon(las, xpoly, ypoly, ...)
lasclipCircle(las, xcenter, ycenter, radius, ...)
}
\arguments{
\item{las}{An object of class \link[lidR:LAS-class]{LAS} or \link[lidR:LAScatalog-class]{LAScatalog}.}
\item{geometry}{a geometric object. Many types are supported, see section 'supported geometries'.}
\item{...}{in \code{lasclip}: optional supplementary options (see supported geometries). Unused in
other functions}
\item{xleft}{numeric. left x coordinates of rectangles.}
\item{ybottom}{numeric. bottom y coordinates of rectangles.}
\item{xright}{numeric. right x coordinates of rectangles.}
\item{ytop}{numeric. top y coordinates of rectangles.}
\item{xpoly}{numeric. x coordinates of a polygon.}
\item{ypoly}{numeric. y coordinates of a polygon.}
\item{xcenter}{numeric. x coordinates of discs centers.}
\item{ycenter}{numeric. y coordinates of discs centers.}
\item{radius}{numeric. disc radius or radii.}
}
\value{
If the input is a \code{LAS} object: an object of class \code{LAS}, or a \code{list} of \code{LAS} objects if the query
implies several regions of interest will be returned.\cr\cr
If the input is a \code{LAScatalog} object: an object of class \code{LAS}, or a \code{list} of \code{LAS} objects if the query
implies several regions of interest will be returned, or a \code{LAScatalog} if the queries are immediately written into files
without loading anything in R.
}
\description{
Clip LiDAR points within a given geometry from a point cloud (\code{LAS} object) or a catalog
(\code{LAScatalog} object). With a \code{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 \code{LAScatalog}
object, the user can extract any arbitrary ROI for a set of \code{las/laz} files, loading only the
points of interest. This is faster, easier and much more memory-efficient for extracting ROIs.
}
\section{Supported geometries}{
\itemize{
\item \href{https://en.wikipedia.org/wiki/Well-known_text}{WKT string}: describing a POINT, a POLYGON or
a MULTIPOLYGON. If points a parameter 'radius' must be passed in \code{...}
\item \link[sp:Polygon-class]{Polygon} or \link[sp:Polygons-class]{Polygons}
\item \link[sp:SpatialPolygons-class]{SpatialPolygons} or \link[sp:SpatialPolygonsDataFrame-class]{SpatialPolygonsDataFrame}
\item \link[sp:SpatialPoints-class]{SpatialPoints} or \link[sp:SpatialPointsDataFrame-class]{SpatialPointsDataFrame}
in that case a parameter 'radius' must be passed in \code{...}
\item \link[sf:sf]{SimpleFeature} that consistently contains \code{POINT} or \code{POLYGON/MULTIPOLYGON}.
In case of \code{POINT} a parameter 'radius' must be passed in \code{...}
\item \link[raster:Extent-class]{Extent}
\item \link[base:matrix]{matrix} 2 x 2 describing a bounding box following this order:
\preformatted{
min max
x 684816 684943
y 5017823 5017957}
}
}
\section{Working with a \code{LAScatalog}}{
This section appears in each function that supports a LAScatalog as input.\cr
In \code{lidR} when the input of a function is a \link[lidR:LAScatalog-class]{LAScatalog} the
function uses the LAScatalog processing engine. The user can modify the engine options using
the \link[lidR:catalog_options_tools]{available options}. A careful reading of the
\link[lidR:LAScatalog-class]{engine documentation} is recommended before processing \code{LAScatalogs}. Each
\code{lidR} function should come with a section that documents the supported engine options.\cr
The \code{LAScatalog} engine supports \code{.lax} files that \emph{significantly} improve the computation
speed of spatial queries using a spatial index. Users should really take advantage a \code{.lax} files,
but this is not mandatory.\cr
}
\section{Supported processing options}{
Supported processing options for a \code{LAScatalog} (in bold). For more details see the
\link[lidR:LAScatalog-class]{LAScatalog engine documentation}:
\itemize{
\item chunk_size: Does not make sense here.
\item buffer: Not supported yet.
\item alignment: Does not makes sense here.
\item \strong{progress}: Displays a progress estimation.
\item \strong{stop_early}: Leave this 'as-is' unless you are an advanced user.
\item \strong{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 \link{LAScatalog-class} and examples. The allowed templates in
\code{lasclip} are \code{{XLEFT}, {XRIGHT}, {YBOTTOM}, {YTOP}, {ID}, {XCENTER},
{YCENTER}} or any names from the table of attributes of a spatial object given as
input such as \code{{PLOT_ID}} or \code{{YEAR}}, for example, if these attributes exist. If empty everything
is returned into R.
\item \strong{laz_compression}: write \code{las} or \code{laz} files
\item \strong{drivers}: Leave this 'as-is' unless you are an advanced user.
\item select: The function will write files equivalent to the originals. This option is not respected.
\item \strong{filter}: Read only the points of interest.
}
}
\examples{
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 = readLAScatalog(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)
\dontrun{
plot(subset1)
plot(subset2)
plot(subset3)
}
}