Main Content

lasFileWriter

LAS or LAZ file writer

Since R2022a

Description

A lasFileWriter object stores metadata for a LAS or LAZ file as read-only properties. The writePointCloud object function uses these properties to write point cloud data as a LAS or LAZ file. The lasFileWriter object supports up to the LAS 1.4 specification.

lasFileWriter supports writing only unorganized pointCloud objects. The created LAS file contains a public header, which contains LAS file metadata, followed by the lidar point records.

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

lasWriter = lasFileWriter(fileName) creates a lasFileWriter object with default properties to write lidar point cloud data into a LAS or LAZ file with the specified name fileName. The fileName input sets the FileName property.

lasWriter = lasFileWriter(fileName,Name=Value) specifies the properties of the lasFileWriter object by using one or more name-value arguments.

Properties

expand all

This property is read-only.

Name of the LAS or LAZ file, specified as a character vector or string scalar. You can specify the extensions .las or .laz. If you do not specify a file extension, the default extension is .laz.

This property is read-only.

LAS or LAZ file version, specified as "1.0", "1.1", "1.2", "1.3", or "1.4".

Example: LasVersion="1.4" specifies the LAS version as 1.4.

This property is read-only.

Point data record format ID, specified as 0, 1, 2, 3, 6, 7, or 8. Which point data record formats you can specify dependents on the specified LasVersion property.

LAS or LAZ VersionSupported Point Data Record Formats
1.0Point data record formats 0 and 1
1.1Point data record formats 0 and 1
1.2Point data record formats 0 to 3
1.3Point data record formats 0 to 3
1.4Point data record formats 0 to 3 and 6 to 8

Note

The point data record format in LAS files ranges from 011. But the lasFileWriter object supports 0, 1, 2, 3, 6, 7, or 8 formats only.

For more information, see Point Data Record Format.

Example: PointDataFormat=2 specifies the point data record format as 2.

This property is read-only.

Scale of the coordinates, specified as "auto" or a three-element real-valued row vector of the form [Xscale Yscale Zscale]. When you call the writePointCloud function, the default value "auto" calculates the XYZScale value using the XLimits, YLimits, and ZLimits properties of the input pointCloud object. For more information, see Point Cloud Data Representation.

Example: XYZScale=[10 20 30] specifies the scale factors of the X-, Y-, and Z-coordinates as 10, 20, and 30 respectively.

This property is read-only.

Offset of the coordinates, specified as "auto" or a three-element real-valued row vector of the form [Xoffset Yoffset Zoffset]. When you call the writePointCloud function, the default value "auto" calculates the XYZOffset value using the XLimits, YLimits, and ZLimits properties of the input pointCloud object. For more information, see Point Cloud Data Representation.

Example: XYZOffset=[5 3 2] specifies the offset values of the X-, Y-, and Z-coordinates as 5, 3, and 2 respectively.

Object Functions

writePointCloudWrite point cloud data to LAS or LAZ file
addVLRAdd VLR data to lasFileWriter object

Examples

collapse all

Create a lasFileReader object to access LAZ file data.

fileName = fullfile(toolboxdir("lidar"),"lidardata","las", ...
    "aerialLidarData.laz");
lasReader = lasFileReader(fileName);

Read the point cloud data from the LAZ file using the readPointCloud function.

ptCloud = readPointCloud(lasReader,Classification=2);

Create a lasFileWriter object to store the point cloud data in a LAS file.

lasWriter = lasFileWriter("ground.las");

Write the point cloud data to the LAS file by using the writePointCloud function.

writePointCloud(lasWriter,ptCloud);

Algorithms

The point cloud coordinate values are calculated as:

x=X*Xscale+Xoffsety=Y*Yscale+Yoffsetz=Z*Zscale+Zoffset

where, Xscale, Yscale, and Zscale are set by the XYZScale property, and Xoffset, Yoffset, and Zoffset are set by the XYZOffset property. X, Y, and Z are the raw coordinate values of the point cloud data. You must specify the [X Y Z] values for each point in a pointCloud object when writing them to a LAS or LAZ file using the writePointCloud function.

Version History

Introduced in R2022a

expand all