Main Content

addVLR

Add VLR data to lasFileWriter object

Since R2022b

    Description

    example

    addVLR(lasWriter,recordID,userID,vlrData) adds the variable length record (VLR) data with the specified record ID and the user ID to the lasFileWriter object lasWriter.

    addVLR(___,description) adds a description for the VLR data.

    Examples

    collapse all

    Create a lasFileReader object to read LAS/LAZ file data into the workspace.

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

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

    ptCloud = readPointCloud(lasReader);

    Create a lasFileWriter object to store the point cloud data read from the file. Specify the filename and the LAS version.

    lasWriter = lasFileWriter("points.las",LasVersion="1.4");

    Add VLR data to the lasFileWriter object using the addVLR function. You must specify the record ID, user ID, and the VLR data.

    addVLR(lasWriter,3,"LASF_Spec","Sample VLR data")

    Write the data into the LAS file using the writePointCloud function.

    writePointCloud(lasWriter,ptCloud)

    Create a lasFileReader object to read LAS/LAZ file data into the workspace.

    filename = fullfile(toolboxdir("lidar"),"lidardata","las", ...
        "aerialLidarData2.las");
    lasReader = lasFileReader(filename);

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

    ptCloud = readPointCloud(lasReader);

    Read CRS data from the VLRs in GeoTIFF format using the readVLR function.

    geoKeyVLR = readVLR(lasReader,34735);
    geoAsciiParamsVLR = readVLR(lasReader,34737);

    Create a lasFileWriter object to store the point cloud data read from the file. Specify the filename and the LAS version.

    lasWriter = lasFileWriter("pointsWithCRS.las",LasVersion="1.4");

    Add geo-keys to the lasFileWriter object.

    addVLR(lasWriter,34735,"LASF_Projection",geoKeyVLR.Data.KeyEntries)

    Add geo-ASCII parameters to the lasFileWriter object.

    addVLR(lasWriter,34737,"LASF_Projection",geoAsciiParamsVLR.Data)

    Write the data into the LAS file using the writePointCloud function.

    writePointCloud(lasWriter,ptCloud)

    Input Arguments

    collapse all

    LAS or LAZ file writer, specified as a lasFileWriter object.

    Record ID for the VLR data, specified as a nonnegative integer in the range [0, 65535]. For some standard record IDs, see VLR and CRS Data.

    Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

    User ID for the VLR data, specified as a character vector or string scalar. This value identifies the user that created the VLR data. For some standard user IDs, see VLR and CRS Data.

    Data Types: char | string

    Variable length record data, specified as a character vector, a string scalar, a structure, or a numeric array. For more information on VLR data for standard record ID and user ID combinations, see VLR and CRS Data.

    Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | char | string | struct

    Description for the VLR data, specified as a character vector or a string scalar.

    Data Types: char | string

    Algorithms

    A LAS or LAZ file contains a public header block, variable length records (VLR), point data records, and extended variable length records (EVLR). VLRs and EVLRs are optional.

    VLRs contain data about the projection information, metadata, waveform, and user information. This table gives the list of some standard VLRs defined in the LAS specification.

    Record IDUser IDVLR Data
    0LASF_Spec A character vector or a string representing the data from the Classification Lookup record.
    3LASF_SpecA character vector or a string representing the ASCII data from the Text Area Description record.
    2111LASF_ProjectionA character vector or a string representing the ASCII data from the OGC Math Transform WKT record.
    2112LASF_ProjectionA character vector or a string representing the ASCII data from the OGC Coordinate System WKT record.
    34735LASF_Projection

    An array of structures representing the data from the GeoTiff key entries of the GeoKeyDirectoryTag record. The structure has these fields:

    • KeyID — The ID for each key of the GeoTIFF data.

    • TiffTagLocation — Indicates the data location for the corresponding key. It can take one of these three values: 0, 34736, or 34737.

    • Count — Indicates the number of characters in the GeoAsciiParamsTag string value. Otherwise, this value is 1.

    • ValueOffset — The offset value for the data location. This value depends on the value of TiffTagLocation.

    34736LASF_ProjectionA double vector representing the numeric values from the GeoDoubleParamsTag record.
    34737LASF_ProjectionA character vector or a string representing the ASCII data from the GeoDoubleParamsTag record.

    Coordinate reference system (CRS) data in a LAS file is represented in the well know text (WKT) or GeoTIFF format.

    • VLRs with record IDs 2111 and 2112, with the user ID LASF_Projection, represent the geo-referencing information for the CRS data using well known text (WKT), in LAS files with point data format, 6 to 10.

    • VLRs with record IDs 34735, 34736, and 34737, with the user ID LASF_Projection, represent the CRS data using GeoTIFF, in LAS files with point data format, 1 to 5.

    For more information on the LAS file format, see the ASPRS LASER (LAS) File Format Exchange Activities page.

    Version History

    Introduced in R2022b