Main Content

lasFileReader

Read point cloud data from LAS or LAZ file

Since R2020b

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 the LAS 1.4 specification.

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

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.

example

Input Arguments

expand all

Name of the LAS or LAZ file, specified as a character vector or string scalar. You must specify the full file path if the LAS or LAZ file is not in your MATLAB® path.

This argument sets the FileName property as a character vector.

Data Types: char | string

Properties

expand all

This property is read-only after object creation. To set this property, use the fileName argument when calling the lasFileReader function.

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, represented as a positive integer.

This property is read-only.

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

This property is read-only.

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

This property is read-only.

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

This property is read-only.

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

Since R2025a

This property is read-only.

Scale of the XYZ coordinates, represented as a three-element real-valued row vector of the form [Xscale Yscale Zscale]. Xscale, Yscale, and Zscale represent the scale along the X-, Y-, and Z-axes, respectively.

Since R2025a

This property is read-only.

Offset of the XYZ coordinates, represented as a three-element real-valued row vector of the form [Xoffset Yoffset Zoffset]. Xoffset, Yoffset, and Zoffset represent the offset along the X-, Y-, and Z-axes, respectively.

Since R2025a

This property is read-only.

List of the available attributes, represented as a string array. Use this property to identify all the attributes present in the file. You can also read all available attributes by using the readPointCloud object function.

This property is read-only.

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

Note

The value of this property is not immediately available. To get the this property for the lasFileReader object, lasReader, type lasReader.GPSTimeLimits in the Command Window. This command also populates the NumClasses and ClassificationInfo properties of the object.

This property is read-only.

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

This property is read-only.

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

Note

The value of this property is not immediately available. To get the this property for the lasFileReader object, lasReader, type lasReader.NumClasses in the Command Window. This command also populates the GPSTimeLimits and ClassificationInfo properties of the object.

This property is read-only.

Name of the hardware sensor system identifier that generated the LAS files, represented as a string scalar.

This property is read-only.

Name of the generating software, represented as a string scalar. This property specifies the generating software package used when the LAS file was created.

This property is read-only.

Date of file creation, represented as a datetime object.

This property is read-only.

LAS file source identifier, represented as a nonnegative integer. Values are in the range 0 to 65535. This defines the flight line number if this file was created from an original flight line. A value 0 specifies that no ID has been assigned. Use the ProjectID and FileSourceID properties to uniquely identify each point in a LAS file.

This property is read-only.

Project ID, represented as a string scalar. This value is a globally unique identifier (GUID). Use the ProjectID and FileSourceID properties to uniquely identify each point in a LAS file.

This property is read-only.

Point data record format ID, represented as a nonnegative integer. Values are in the range 0 to 10. For more information, see Point Data Record Format.

This property is read-only.

Classification information, represented as a table. Each row of the table contains this information describing a point class:

  • Classification Value — Unique classification ID number for the class, represented as a positive integer.

  • Class Name — Label associated with the class, represented as a string scalar.

  • Number of Points by Class — Number of points in the class, represented as a positive integer.

Note

The value of this property is not immediately available. To get the this property for the lasFileReader object, lasReader, type lasReader.ClassificationInfo in the Command Window. This command also populates the GPSTimeLimits and NumClasses properties of the object.

This property is read-only.

Laser return information, represented as a table. Each row of the table contains this information describing a laser return:

  • Laser Return Number — Laser return number, represented as a positive integer.

  • Number of Points by Return — Number of points per laser return, represented as a positive integer.

This property is read-only.

Variable length record (VLR) or extended VLR information, represented as a table. Each row of the table contains this information describing a record:

  • Record ID — Record identification number, represented as a positive integer.

  • User ID — User identification associated with record ID, represented as a string scalar.

  • Description — Description of record, represented as a string scalar.

Object Functions

readPointCloudRead point cloud data from LAS or LAZ file
readCRSRead coordinate reference system data from LAS or LAZ file
readVLRRead variable length record from LAS or LAZ file

Examples

collapse all

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)

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

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.

More About

expand all

Version History

Introduced in R2020b

expand all