LAS Format Definition

OPALS supports reading and writing of files in ASPRS LAS format (see also here). OPALS additionally supports the losslessly compressed twin of LAS, the LAZ format. When specifying a LAS or LAZ file path without an OPALS Format Definition (OFD), the file is imported or exported with default parameters. An OFD containing the XML element <las>, however, allows for the specification of the LAS format version, the LAS point data record format, and the coordinate offsets and scales to be used on export. Additionally, it allows for importing/exporting arbitrary ODM attributes as extra bytes that are appended to each point record, and whose semantics are stored in an Extra Bytes Variable Length Record (VLR).

LAS Format Version, Point Data Record Format, and Coordinate Scale

Each LAS format version supports a certain set of point data record formats:

LAS format versions' support of point data record formats
LAS format version Supported point data record formats
0 1 2 3 4 5 6 7 8 9 10

The point data record format defines the (minimum) set of attributes that LAS stores for each point:

Attributes stored by different point data record formats
ODM attribute point data record format Las spec.'s name
0 1, 4 2 3, 5 6, 9 7 8, 10
Amplitude Intensity
EchoNumber 1) Return Number
NrOfEchos 1) Number of Returns (given pulse)
ClassificationFlags Classification flags
ChannelDesc Scanner Channel
ScanDirection Scan Direction Flag
EdgeOfFlightLine Edge of Flight Line
Classification 1) Classification
UserData User Data
ScanAngle 1) Scan Angle / Scan Angle Rank
PointSourceId Point Source ID
GPSTime GPS Time
Red Red
Green Green
Blue Blue
InfraRed NIR

1) Point data record formats 6-10 reserve more space for storage of EchoNumber, NrOfEchos, Classification, and ScanAngle. Hence, EchoNumber/NrOfEchos in the range [0-15] (vs. [0-7]), and Classification in the range [0-255] (vs. [0-31]) can be stored. Also, formats 6-10 store ScanAngle with the higher resolution of 0.006° (vs. 1°), and a valid range of ± 180° (vs. ± 90°).

As OPALS does not support LAS Wave Packets, pairs of point data record formats (1,4), (3,5), (6,9), and (8,10) yield the same information on disk, while the latter of each pair yields larger file sizes.

Note that these attribute sets may be extended by usage of Extra Bytes.

LAS OFDs may specify the LAS format version, the point data record format, and the coordinate offsets and scales to be used on export, using the XML attributes / elements

  • <versionMinor>
  • <pointDataRecordFormat>
  • <offsetCoordinates>
  • <scaleCoordinates>.

In the following snippet from an according OFD file, the format version is set to 1.2, and the point data record format is set to 1:

A complete LAS OFD that exports to LAS 1.2 can be found at $OPALS_ROOT/addons/formatdef/LAS_1.2.xml. All of these XML attributes / elements are optional. If absent, the respective default values are used i.e. format version 1.1, point data record format 0, and coordinate scales 0.001. If not specified, the coordinate offsets are set to the mid points of the ranges of coordinates to be exported.

Currently, all LAS format versions up to 1.4 and point data record formats up to 10 are supported. For detailed information on the LAS format versions, see the respective ASPRS LAS format specifications

The Optimal Coordinate Scale

Upon writing to LAS files, each coordinate value \(X_{world}\) is reduced by a coordinate-specific offset \(X_{offset}\) and scale \(X_{scale}\), and then rounded to the nearest whole number \(X_{LAS}\), according to the following equation:

\[ X_{world} = X_{LAS} \cdot X_{scale} + X_{offset} \]

The resulting shifted and scaled coordinates are then rounded to whole numbers and stored on file. Thus, if the measurement unit of coordinates is the metre, then the default coordinate scales mean that coordinates are stored with millimitre-precision. Using larger coordinate scales causes more significant digits to be truncated i.e. more precision to be lost. When storing to compressed LAS files (LAZ), compression will then probably work more efficiently, leading to smaller file sizes.

If you aim at storing coordinates with the highest precision possible that won't lead to a numerical overflow, then instead of a numerical value, specify min as coordinateScale. This sets the scales to the reciprocals of the coordinate ranges and will not affect the size of uncompressed LAS files.

Extra Bytes

Since its initial specification, LAS has allowed for appending arbitrary amounts of bytes to each point record, where the number of appended bytes must be the same for all point records. LAS format version 1.4 standardized the documentation of the semantics of these "extra bytes" in the LAS file header, in a so-called Variable Length Header (VLR). These semantics include a name, description, data type, and the number of elements (up to 3). Like point coordinates, "extra bytes" may be offset and scaled. Using this transformation, "extra bytes" may e.g. be stored with reduced precision. Furthermore, a data value that is to be interpreted as invalid (as found on file, disregarding offset and scale) may be specified. Even though only LAS 1.4 introduced this standard, OPALS supports reading and writing those extra bytes documentations for all LAS versions.

LAS OFDs may contain one or more of those specifications, which yield their documentation in the VLR, and the respective attribute(s) being imported/exported from/to each point record. Note that in order to simply import all extra bytes as custom attributes, you may call Module Import without a LAS OFD.

Each <extraBytes> element defines an extra bytes entry in the VLR, with name lasName. Each <extraBytes> element relates to between 1 and 3 ODM attributes. However, note that LAS 1.4 R14 deprecated multi-element extra bytes, and only their import is supported. Only the ODM attribute name (XML-attribute name) must always be specified, while further XML-attributes may be relevant or even mandatory - depending on the usage of predefined or user-defined ODM attributes (see here), and whether the LAS OFD is only used for import (I), or also for export (E):

LAS OFD XML-attributes for Extra Bytes
lasName I/E the name of the extra bytes entry in the LAS file header name
lasDescription E textual description of entry, e.g. units, etc. <empty>
lasType E data type in the LAS file name's data type
name I/E the OPALS attribute's name of the first LAS element
name2 I the OPALS attribute's name of the second LAS element
name3 I the OPALS attribute's name of the third LAS element
type I OPALS data type to be used for a user-defined attribute type stored on file or double, if file defines scale or offset
invalidValue E the value to be stored (unreduced, unscaled) if a point does not feature the attribute 0
scale E the scale to be used <see text>
offset E the offset to be used <see text>

Default values are used where appropriate. Specifications that are irrelevant for the current direction of file access are ignored: e.g. the specification of an invalidValue in a LAS OFD is ignored upon importing from a LAS file, because the file may or may not define such a value already, which OPALS respects - thus, an invalidValue in a LAS OFD is considered only during export. The final mapping between LAS extra bytes and ODM attributes can be found in the Log file.

For the specification of data types (lasType, type), use their XML representations.

Upon storing an ODM attribute with a data type that is different from its ODM data type, scale and offset are automatically adjusted to prevent numerical over-/underflows, unless they are set explictly in the OFD, in which case they are used unchanged, and thus over-/underflows may occur.

While numeric values may be provided as the value of invalidValue, also the following identifiers may be used, which are translated internally to numeric values, according to the number type:

  • Max: maximum representable value
  • Min: meaningful only for signed integers and floating-point numbers. For unsigned integers: zero
  • NaN: supported for floating-point numbers only: quiet (non-signaling) "Not-a-Number"
  • Inf: supported for floating-point numbers only: positive infinity

For exporting point data to a LAS file that augments each point with normal vectors (see Module Normals) and an echo ratio (see Module EchoRatio), a snippet from an appropriate OFD file could look like:

As the point data record format is set to 1, the LAS file also contains GPS time information for each point. For the complete OFD file, see $OPALS_ROOT/addons/formatdef/LAS_1.4_extra_bytes.xml.


Example OFD file 'LAS_1.2.xml'

The file can be found in the $OPALS_ROOT/addons/formatdef/ directory

<description>LAS 1.2 PDRF 1</description>
<!-- Export as LAS Format version 1.2, point data record format 1.
Valid, but irrelevant for import -->
<las versionMinor='2' pointDataRecordFormat='1'/>

Example OFD file 'LAS_1.4_extra_bytes.xml'

The file can be found in the $OPALS_ROOT/addons/formatdef/ directory

<description>LAS 1.4 with extra bytes</description>
Export as LAS Format version 1.4,
with extra bytes for the predefined attributes
- NormalX, NormalY, NormalZ
- EchoRatio
If a LAS file to be imported does not contain the specified extra bytes,
then the <extraBytes> specifications are ignored.
<las versionMinor='4' pointDataRecordFormat='1'>
<extraBytes name='NormalX' lasDescription='unit normal vector X' invalidValue='NaN' />
<extraBytes name='NormalY' lasDescription='unit normal vector Y' invalidValue='NaN' />
<extraBytes name='NormalZ' lasDescription='unit normal vector Z' invalidValue='NaN' />
<extraBytes name='EchoRatio' invalidValue='NaN' />