readPointCloud
Syntax
Description
[
reads the specified point attributes ptCloud
,ptAttributes
] = readPointCloud(lasReader
,"Attributes",ptAtt
)ptAtt
from a LAS or LAZ file. In
addition to the point cloud, the function returns the specified attributes of each point
in the point cloud.
[___] = readPointCloud(___,
specifies options using one or more name-value pair arguments in addition to any of the
argument combinations in previous syntaxes. For example,
Name,Value
)"ROI"
,[5 10 5 10 5 10]
sets the region of interest
(ROI) in which the function reads the point cloud.
Examples
Read Point Cloud Data from LAZ File
This example shows how to read and visualize point cloud data from a LAS / LAZ file.
Create a lasFileReader
object for a LAZ file. Then, use the readPointCloud
function to read point cloud data from the LAZ file and generate a pointCloud
object.
Create a lasFileReader
object to access the LAZ file data.
filepath = fullfile(toolboxdir("lidar"),"lidardata", ... "las","aerialLidarData.laz"); lasReader = lasFileReader(filepath);
Read point cloud data from the LAZ file using the readPointCloud
function.
ptCloud = readPointCloud(lasReader);
Visualize the point cloud.
figure pcshow(ptCloud.Location)
Visualize Point Cloud Based on Classification Data from LAZ File
Segregate and visualize point cloud data based on classification data from a LAZ file.
Create a lasFileReader
object to access data from the LAZ file.
path = fullfile(toolboxdir("lidar"),"lidardata", ... "las","aerialLidarData.laz"); lasReader = lasFileReader(path);
Read point cloud data and associated classification point attributes from the LAZ file using the readPointCloud
function.
[ptCloud,pointAttributes] = readPointCloud(lasReader,"Attributes","Classification");
Color the points based on their classification attributes. Reshape the label image into the shape of the point cloud.
labels = label2rgb(pointAttributes.Classification); colorData = reshape(labels,[],3);
Visualize the color-coded point cloud.
figure pcshow(ptCloud.Location,colorData)
Input Arguments
lasReader
— LAS or LAZ file reader
lasFileReader
object
LAS or LAZ file reader, specified as a lasFileReader
object.
ptAtt
— Point attributes
[ ] (default) | character vector | string scalar | cell array of character vectors | vector of strings
Point attributes, specified as a character vector, string scalar, cell array of character vectors, or vector of strings. The input must contain one or more of these options:
"Classification"
"GPSTimeStamp"
"LaserReturn"
"NumReturns"
"NearIR"
"ScanAngle"
"UserData"
"PointSourceID"
"ScannerChannel"
"ScanDirectionFlag"
"EdgeOfFlightLineFlag"
"WaveformData"
The function returns the specified attributes of each point in a lidarPointAttributes
object, ptAttributes
. The
unspecified attributes are returned empty.
Data Types: char
| string
| cell
Name-Value Arguments
Specify optional pairs of arguments as
Name1=Value1,...,NameN=ValueN
, where Name
is
the argument name and Value
is the corresponding value.
Name-value arguments must appear after other arguments, but the order of the
pairs does not matter.
Before R2021a, use commas to separate each name and value, and enclose
Name
in quotes.
Example: "ROI"
,[5 10 5 10 5 10]
sets the region of
interest (ROI) in which the function reads the point cloud.
ROI
— ROI to read in the point cloud
[-inf inf -inf inf -inf inf]
(default) | six-element row vector
ROI to read in the point cloud, specified as the comma-separated pair consisting
of 'ROI'
and a six-element row vector in the order,
[xmin
xmax
ymin
ymax
zmin
zmax]. Each element must be a real number.
The values specify the ROI boundaries in the x-,
y-, and z-axis.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
GpsTimeSpan
— Range of GPS timestamps
lasReader.GPSTimeLimits
(default) | two-element vector of duration
objects
Range of GPS timestamps, specified as the comma-separated pair consisting of
'GpsTimeSpan'
and a two-element vector of
duration
objects, that denotes [startTime
endTime]. The timestamps must be positive.
Data Types: duration
Classification
— Classification numbers of interest
lasReader.ClassificationInfo.("Classification
Value")
(default) | vector of valid classification numbers
Classification numbers of interest, specified as the comma-separated pair
consisting of 'Classification'
and a vector of valid classification
numbers.
Valid classification numbers range from 0 to 255.
Classification Number | Classification Type |
---|---|
0 | Created, never classified |
1 | Unclassified |
2 | Ground |
3 | Low vegetation |
4 | Medium vegetation |
5 | High vegetation |
6 | Building |
7 | Low point (noise) |
8 | Reserved |
9 | Water |
10 | Rail |
11 | Road surface |
12 | Reserved |
13 | Wire guard (shield) |
14 | Wire conductor (phase) |
15 | Transmission tower |
16 | Wire-structure connector (insulator) |
17 | Bridge deck |
18 | High noise |
19
| Overhead structure |
20 | Ignored ground |
21 | Snow |
22 | Temporal exclusion |
23 - 63 | Reserved |
64 - 255 | User-defined |
These are standard class names and class-object mappings. The class definition and mapping might differ from the standard depending on the application that created the LAS or LAZ file.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
LaserReturn
— Number of points segregated by their return numbers
1:lasReader.NumReturn
(default) | vector of valid return numbers
Number of points segregated by their return numbers, specified as the
comma-separated pair consisting of 'LaserReturn'
and a vector of
valid return numbers. Valid return numbers are integers from 1 to the value of the
NumReturns
property of the input lasFileReader
object.
For each value, i, in the vector, the function returns a point
cloud of only the points that have i as their return number.
The return number is the number of times a laser pulse reflects back to the sensor.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
Output Arguments
ptCloud
— Point cloud
pointCloud
object
Point cloud, returned as a pointCloud
object.
ptAttributes
— Point attribute data
lidarPointAttributes
object
Point attribute data, returned as a lidarPointAttributes
object. The object contains data for the specified
attributes ptAtt
of each point in the ptCloud
output.
Version History
Introduced in R2020bR2022a: Additional point attributes
You can now specify these additional point attributes to the ptAtt
argument:
"UserData"
"PointSourceID"
"ScannerChannel"
"ScanDirectionFlag"
"EdgeOfFlightLine"
"WaveformData"
R2022a: LaserReturns
renamed to LaserReturn
The LaserReturns
is now called LaserReturn
. To
update your code, replace all instances of the LaserReturns
argument with
LaserReturn
.
R2022a: Point attributes returned as object
The readPointCloud
function returns the
ptAttributes
argument as a lidarPointAttributes
object instead of as a structure.
See Also
Functions
Objects
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)