Main Content

lasFileReader

LAS or LAZ file reader

Description

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.

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.

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.

Creation

Description

example

lasReader = lasFileReader(fileName) reads the metadata from a LAS or LAZ file, fileName, and stores it as properties of an output lasFileReader object, lasReader. 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 vector.

This property is read-only.

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

This property is read-only.

Range of coordinates along the z-axis, specified as a two-element 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.

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

Visualize the color-coded point cloud.

figure
pcshow(ptCloud.Location,colorData)

Introduced in R2020b