lasFileReader
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
Input Arguments
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
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
readPointCloud | Read point cloud data from LAS or LAZ file |
readCRS | Read coordinate reference system data from LAS or LAZ file |
readVLR | Read variable length record from LAS or LAZ file |
Examples
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)
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)
More About
A LAS file contains point cloud data as a collection of point data records, as well as a public header block and optional metadata information about the records. The public header block indicates the point numbers and point data bounds of the LAS file, as well as the point data record format.
As of the LAS 1.4 specification, there are 11 point data record formats, ranging from Point Data Record Format 0 to Point Data Record Format 10, divided into two major groups.
Point Data Record Format 0 to Point Data Record Format 5 — These formats contain 20 core bytes, with formats 1–5 adding optional information about GPS time, color channels, or wave packets.
Point Data Record Format 6 to Point Data Record Format 10 — These formats contain 30 core bytes, with formats 7–10 adding optional information about color channels, near IR, or wave packets.
For more information, including which point data record formats are available for each version of the LAS file specification, see the ASPRS LASER (LAS) File Format Exchange Activities page.
Version History
Introduced in R2020bThe lasFileReader
object includes these additional properties to read
scale and offset values of the XYZ coordinates from the input LAS or LAZ file.
Scale
Offset
The object also includes Attributes
property. Use this property to get
the list of available attributes in the input LAS or LAZ file.
The lasFileReader
function shows improved performance for creating
a lasFileReader
object. The performance improvement increases as the number of available point records
increases in the input LAS or LAZ file. For example, this code is about 118x faster than in
the previous release:
function t = timingTest pcfile = fullfile(toolboxdir("lidar"),"lidardata","las","aerialLidarData.laz"); lasReader = @()lasFileReader(pcfile); t = timeit(lasReader); end
The approximate execution times are:
R2024b: 0.39 s
R2025a: 0.0033 s
The code was timed on a Windows® 10, Intel®
Xeon® Gold 6240R CPU@ 2.40 GHz test system by calling the function
timingTest
.
The object shows improved performance because it does not immediately populate the
GPSTimeLimits
, NumClasses
, and
ClassificationInfo
properties after creation. Therefore, unlike the
previous release, the creation time for the object is independent of the number of point
records in the input file. To populate these properties, view or extract one of them. For
example, using this command to view the GPSTimeLimits
property of a
lasFileReader
object, lasReader
, also populates the
NumClasses
and ClassificationInfo
properties of
the object.
These object functions of the lasFileReader
object will be removed in a future release:
hasCRSData
— To check for CRS data in a LAS or LAZ file, use~isempty(readCRS(lasReader))
instead ofhasCRSData(lasReader)
.hasGPSData
— To check for GPS data in a LAS or LAZ file, useany(lasReader.Attributes == "GPSTimeStamp")
instead ofhasGPSData(lasReader)
.hasWaveformData
— To check for waveform data in a LAS or LAZ file, useany(lasReader.Attributes == "WaveformData")
instead ofhasWaveformData(lasReader)
.hasNearIRData
— To check for near IR data in a LAS or LAZ file, useany(lasReader.Attributes == "NearIR")
instead ofhasNearIRData(lasReader)
.
The lasFileReader
object includes these additional properties:
SystemIdentifier
GeneratingSoftware
FileCreationDate
FileSourceID
ProjectID
PointDataFormat
ClassificationInfo
LaserReturnInfo
VariableLengthRecords
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)