Introduction
PTX is the plain text export of gridded laser scans from Leica Geosystems’ Cyclone software, also read by other point cloud programs. A file holds one or more scans. Each keeps its points in the scanner’s own coordinate system, in the order of the scan grid, and carries a header that places the scan in a common, registered coordinate system. Coordinates are in metres.
It differs from PTS, which has a point count and no scanner position, matrix or grid. Binary formats such as E57 hold the same kind of data far more compactly.
Structure
The file is text, one record per line, with values separated by spaces. There is no signature, version number or file header. A scan is ten header lines followed by one line for every cell of its grid, columns × rows lines in all. If the file holds more scans, the next header starts on the line after the last point; the file ends after the last scan.
Scan header
| Line | Values | Meaning |
|---|---|---|
| 1 | 1 integer | Number of columns of the scan grid. |
| 2 | 1 integer | Number of rows of the scan grid. |
| 3 | 3 numbers | Registered position of the scanner, x y z. |
| 4 | 3 numbers | Registered X axis of the scanner. |
| 5 | 3 numbers | Registered Y axis of the scanner. |
| 6 | 3 numbers | Registered Z axis of the scanner. |
| 7 | 4 numbers | Transformation matrix, first row: r11 r12 r13 0. |
| 8 | 4 numbers | Second row: r21 r22 r23 0. |
| 9 | 4 numbers | Third row: r31 r32 r33 0. |
| 10 | 4 numbers | Fourth row, the translation: tx ty tz 1. |
The header numbers should be read in double precision, since registered coordinates are often large survey coordinates.
Scanner pose and matrix
Lines 3 to 6 give where the scanner is after registration, and the directions of its three axes.
For a scan that registration has not moved they are 0 0 0, 1 0 0,
0 1 0 and 0 0 1.
Lines 7 to 10 are the 4×4 matrix that is applied to the points. It is written for row vectors, with the translation in the last row:
x' = x·r11 + y·r21 + z·r31 + tx
y' = x·r12 + y·r22 + z·r32 + ty
z' = x·r13 + y·r23 + z·r33 + tz
x y z of the scan.The two blocks often repeat each other, but they need not. When a user coordinate system was active at export, the matrix differs from lines 3 to 6; it can even be the identity for a registered scan, if that coordinate system was set at the scanner’s registered position. To place the points, use the matrix.
As an example, a scan turned 90 degrees about Z and moved to 10 20 0 has these lines 3
to 10 when no user coordinate system applies. Its point 1 2 3 lands at
8 21 3.
10 20 0
0 1 0
-1 0 0
0 0 1
0 1 0 0
-1 0 0 0
0 0 1 0
10 20 0 1
Point lines
A point line has four values, or seven when the scan has colour.
| Position | Value | Meaning |
|---|---|---|
| 1–3 | x y z | Position in the scan’s own coordinate system, in metres. |
| 4 | intensity | Strength of the return, a decimal number from 0 to 1. |
| 5–7 | red green blue | Colour from the scanner’s camera, integers from 0 to 255. Only in the seven-value layout. |
In a coloured scan the colour 0 0 0 means “no colour”, for example where the camera did
not cover the point.
Grid order and missing points
Every cell of the grid has a line. A cell with no measurement is written with the position
0 0 0, often as 0 0 0 0.500000 0 0 0 in coloured files. Readers must keep
counting these lines, and may leave the points out.
The lines run column by column: all rows of the first column, then all rows of the second, and so on. Point line k, counted from zero, is column k divided by the row count (rounded down) and row k modulo the row count. This order lets software rebuild the scan grid, for example to estimate surface normals.
Example
2
2
0 0 0
1 0 0
0 1 0
0 0 1
1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1
1.204 0.551 -1.010 0.412 128 120 110
1.206 0.553 -0.998 0.405 131 122 112
0 0 0 0.500000 0 0 0
1.213 0.560 -0.996 0.398 129 121 111
Recognising a file
With no magic number, a PTX file is recognised by the shape of its first ten lines: two lines with one positive integer each, four lines with three numbers each, and four lines with four numbers each, of which the first three end in 0 and the last in 1. The next line has four or seven numbers.
Divergence in software
- CloudCompare 2.10.1 reads PTX but does not write it. It requires exactly three or four values on
the header lines, four or seven on point lines, and whole-number colours up to 255. It rebuilds
both the axes and the matrix rotation as unit vectors at right angles, so any scale in them is
lost, and it leaves out cells at
0 0 0while keeping their place in the grid. - PDAL’s reader skips lines 3 to 6 and applies the matrix. It takes the column layout from the
first point of the file and ignores later lines with a different number of values. It scales
intensity by 4096 and by default drops points at
0 0 0. - Easy3D applies the matrix and decides for each scan from its first point line whether it has colour. It keeps the empty cells as points.
- Paul Bourke’s description notes that some files write colours as decimals from 0 to 1. CloudCompare 2.10.1 refuses those.
- A comment in PDAL’s reader says a ten-value layout with normals may exist, but that its author found no example; the Leica description gives only four and seven.
To turn PTS intensities, whole numbers from −2048 to 2047, into PTX intensities, add 2048 and divide by 4096.
In the explorer
A dropped .ptx file that starts with a scan header opens as a point cloud; NVIDIA PTX
assembly keeps its own entry. The file is read in pieces as it is needed, so no size limit is
set.
- 3D view: all scans together, each placed by its matrix, with the file’s colour, or its intensity as grey. A file with more than 1,000,000 measured points opens as every second, third or further point, followed by parts of 1,000,000 point lines that between them show every point.
- Scans: each scan’s ten header lines, whether its matrix repeats the position and axes, counts of measured, empty and unreadable cells, value ranges and registered bounds, its own 3D view and its grid as intensity and colour pictures. A large grid has a reduced picture of the whole and tiles of 1,024 × 1,024 cells with every cell.
- Data and tree: every point line, in pages, with its column, row, values and registered position, linked to its bytes.
- Text and problems: the whole text, and each line that departs from the layout. Values after the seventh, as in the unconfirmed ten-value layout, are listed but given no meaning.
Not described
Leica’s knowledge base article on the format is no longer at its address; its description is taken from the copy quoted in Easy3D’s source, checked against Paul Bourke’s page and three readers.
Also used for
- NVIDIA PTX assembly – NVIDIA’s virtual assembly language for CUDA kernels, as text.
- Pro Tools session – An Avid Pro Tools session: an obfuscated binary file beside an Audio Files folder.
Links
Software
- Leica Cyclone – Leica Geosystems’ laser scanning software, where the format comes from (Windows)
- CloudCompare – free open source point cloud tool that imports PTX (Windows, macOS, Linux)
Developers
- PDAL readers.ptx – the PDAL PTX reader (C++)
- Easy3D – 3D geometry library with a PTX reader (C++)
Reference
- Easy3D point_cloud_io_ptx.h – quotes Leica’s description of the format
- ptx plain text data format – Paul Bourke’s description with an example
- PDAL PtxReader.cpp – PDAL’s reader
- CloudCompare PTXFilter.cpp, 2.10.1 – grid order and checks made on import