readPointCloud

Read point cloud data from a LAS or LAZ file

Description

example

ptCloud = readPointCloud(lasReader) reads the point cloud data from the LAS or LAZ file indicated by the input lasFileReader object and returns it as a pointCloud object, ptCloud.

example

[ptCloud,ptAttributes] = readPointCloud(lasReader,'Attributes',ptAtt) reads specified point attributes, ptAtt, from a LAS or LAZ file. In addition to the point cloud, the function returns a structure, ptAttributes, containing the specified attributes of each point in the point cloud.

[___] = readPointCloud(___,Name,Value) specifies options using one or more name-value pair arguments in addition to any of the argument combinations in previous syntaxes. For example, 'ROI',[5 10 5 10 5 10] sets the region of interest (ROI) in which the function reads the point cloud.

Examples

collapse all

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.

path = fullfile(toolboxdir('lidar'),'lidardata', ...
    'las','aerialLidarData.laz');
lasReader = lasFileReader(path);

Read point cloud data from the LAZ file using the readPointCloud function.

ptCloud = readPointCloud(lasReader);

Visualize the point cloud.

figure
pcshow(ptCloud.Location)

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.

colorData = reshape(label2rgb(pointAttributes.Classification),[],3);

Visualize the color-coded point cloud.

figure
pcshow(ptCloud.Location,colorData)

Input Arguments

collapse all

LAS or LAZ file reader, specified as a lasFileReader object.

Point attributes, specified as a character vector, string scalar, cell array of character vectors, or string array. The input must contain one or more of these options:

  • "Classification"

  • "GPSTimeStamp"

  • "LaserReturns"

  • "NearIR"

  • "ScanAngle"

Each specified point attribute is returned as a field in the name of structure ptAttributes.

Data Types: char | string

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside quotes. You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: 'ROI',[5 10 5 10 5 10] sets the region of interest (ROI) in which the function reads the point cloud.

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

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 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 NumberClassification Type
0Created, never classified
1Unclassified
2Ground
3Low vegetation
4Medium vegetation
5High vegetation
6Building
7Low point (noise)
8Reserved
9Water
10Rail
11Road surface
12Reserved
13Wire guard (shield)
14Wire conductor (phase)
15Transmission tower
16Wire-structure connector (insulator)
17Bridge deck
18High noise
19 - 63Reserved
64 - 255User-defined

These are standard classes and class-object mappings might differ from the standard classes depending on the application that created the LAS or LAZ file.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Number of points segregated by their return numbers, specified as the comma-separated pair consisting of 'LaserReturns' 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

collapse all

Point cloud, returned as a pointCloud object.

Point attributes data, returned as a structure of fields that correspond to point attributes. The ptAtt input specifies the fields for this structure. The structure contains data for the specified attributes of each point in the ptCloud output.

Data Types: struct

Introduced in R2020b