Main Content

lasFileReader

LAS or LAZ file reader

Description

A lasFileReader object stores the metadata present in the LAS or LAZ file as read-only properties. The object function, readPointCloud, uses these properties to read point cloud data from the file. The lasFileReader object supports up to LAS 1.4 version.

A LAS file contains a public header, which has lidar metadata, followed by lidar point records. Each point record contains attributes such as 3-D coordinates, intensity and GPS timestamp.

The LAS file format is an industry-standard binary format for storing lidar data, developed and maintained by the American Society for Photogrammetry and Remote Sensing (ASPRS). The LAZ file format is a compressed version of the LAS file format.

Creation

Description

example

lasReader = lasFileReader(fileName) creates a lasFileReader object with Properties set by reading the metadata present in the LAS or LAZ file, fileName. The fileName input sets the FileName property.

Properties

expand all

This property is read-only.

Name of the LAS or LAZ file, specified as a character vector or string scalar.

This property is read-only.

Number of available point records in the file, specified as a positive integer.

This property is read-only.

LAS or LAZ file version, specified as a character vector.

This property is read-only.

Range of coordinates along the x-axis, specified as a two-element row real-valued vector.

This property is read-only.

Range of coordinates along the y-axis, specified as a two-element real-valued row vector.

This property is read-only.

Range of coordinates along the z-axis, specified as a two-element real-valued row vector.

This property is read-only.

Range of GPS timestamp readings, specified as a 1-by-2 duration vector.

This property is read-only.

Maximum of all point laser returns, specified as a positive integer.

This property is read-only.

Maximum of all point classification values, specified as a positive integer.

Object Functions

readPointCloudRead point cloud data from a LAS or LAZ file

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. 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)

Figure contains an axes object. The axes object contains an object of type scatter.

Introduced in R2020b