Main Content

lasFileReader

LAS or LAZ file reader

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

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 real-valued row 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.

This property is read-only.

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

This property is read-only.

Name of the generating software, specified 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, specified as a datetime object.

This property is read-only.

LAS file source identifier, specified 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, specified 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, specified 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, specified as a table. Each row of the table contains this information describing a point class:

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

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

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

This property is read-only.

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

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

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

This property is read-only.

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

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

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

  • Description — Description of record, specified 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
hasCRSDataCheck if LAS or LAZ file has CRS data
hasGPSDataCheck if LAS or LAZ file has GPS data
hasWaveformDataCheck if LAS or LAZ file has waveform data
hasNearIRDataCheck if LAS or LAZ file has near IR data

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