This page follows the Point Cloud Library’s description of PCD version 0.7, the
version PCL treats as official, and its reader, pcd_io.cpp. Earlier
versions (0.5, 0.6) date from before PCL 1.0; a file without a
VIEWPOINT line is read as version 0.6.
Header
The header is ASCII text, one entry per line, each line ended by a line feed. A line
starting with # is a comment. The entries must appear in this order:
| Entry | Values | Meaning |
|---|---|---|
VERSION | One | File version, such as 0.7 or .7 |
FIELDS | One per field | Field names, such as x y z rgb or normal_x normal_y normal_z. Older files may say COLUMNS. A field named _ is padding and is skipped |
SIZE | One per field | Bytes in one element of each field: 1, 2, 4 or 8 |
TYPE | One per field | I signed integer, U unsigned integer, F floating point |
COUNT | One per field | Elements in each field, such as 308 for a VFH descriptor histogram; 1 for each field if the line is missing |
WIDTH | One | Points per row of an organised cloud, or all the points of an unorganised one |
HEIGHT | One | Rows of an organised cloud, or 1 for an unorganised one |
VIEWPOINT | Seven | Sensor position tx ty tz and orientation as a quaternion qw qx qy qz; default 0 0 0 1 0 0 0 |
POINTS | One | Total number of points, WIDTH × HEIGHT |
DATA | One | ascii, binary or binary_compressed; the data starts right after this line |
Field types
| TYPE | SIZE | Meaning |
|---|---|---|
I | 1, 2, 4, 8 | int8, int16, int32, int64 |
U | 1, 2, 4, 8 | uint8, uint16, uint32, uint64 |
F | 4, 8 | float32, float64 |
B | the size of a C++ bool (1 on common platforms) | bool |
The documentation lists sizes up to 4 for integers; PCL’s own code
(getFieldType in common/io.h) accepts 8-byte integers
(I 8, U 8) as well. The type letter is read case-insensitively,
and any other size and letter combination is an invalid type. Invalid values are usually
stored as NaN. For an invalid pair (for example F 2) getFieldType
returns -1, which the reader stores as datatype 255; getFieldSize of that
is 0, so the field is kept by name but its values are not read (the ASCII reader
warns and skips them).
Colour
PCL stores colour in one 4-byte field named rgb or rgba
whose bytes are the colour packed as 0x00RRGGBB (or
0xAARRGGBB). In binary data the four bytes are therefore blue, green,
red, then alpha or 0. In PCL’s point types (point_types.hpp)
PointXYZRGB and PointXYZRGBNormal register rgb as
a float, while PointXYZRGBA, RGB,
PointXYZRGBL and PointSurfel register rgba as a
uint32. The writer for typed clouds
(generateHeader<PointT>, pcd_io.hpp line 76) writes the
TYPE of a field named rgb as U in every DATA form, so the
files it writes say TYPE U for both rgb and rgba.
Only the PCLPointCloud2 writers for binary and binary_compressed write the
field’s own type (F for a float rgb), so both are found in
files. The ASCII writer
(pcd_io.cpp) likewise writes the TYPE of a field named rgb as
U and prints its value as an unsigned integer, even when the data is a
float, “because several fully opaque color values are mapped to nan”; older files wrote
the bytes read as a float in ASCII, such as 4.2108e+06. A reader accepts an
rgb field of TYPE F or U (count 1) and lets
rgb and rgba stand for each other when loading into a point
type.
How PCL reads the header
From PCDReader::readHeader in pcd_io.cpp. PCL’s reader is
forgiving in some places and strict in others:
- The header is read line by line; empty lines are skipped, and a line whose first
word starts with
#is a comment, anywhere in the header. A line is split into words at spaces, tabs and carriage returns, so a CR LF line end is tolerated. A keyword is recognised by its first letters (for exampleVERSIONis matched on 7 letters), and theVERSIONline itself is not interpreted. Matching is case-sensitive. - An unknown header keyword ends header reading. A line whose first word is not
VERSION,FIELDS/COLUMNS,SIZE,TYPE,COUNT,WIDTH,HEIGHT,VIEWPOINT,POINTSorDATAfalls through to the finalbreakof the loop (pcd_io.cpplines 169-341), which leaves the data position at its initial value 0; it is not skipped. - PCL decides the version from
VIEWPOINTalone: version 0.6 (PCD_V6) by default, 0.7 once aVIEWPOINTline is seen. With noVIEWPOINTthe origin is 0 0 0 and the orientation the identity quaternion. AVIEWPOINTline needs seven numbers, or the file is rejected. FIELDS(orCOLUMNS) sets the field names and, until later lines say otherwise, makes every field a float32 with count 1 (so a file withoutSIZEandTYPEis read as all float32). The number of words inSIZE,TYPEandCOUNTmust equal the number of fields.TYPEbeforeSIZE,COUNTbeforeSIZEorTYPE, andPOINTSbefore the fields are known are all errors, so the orderFIELDS,SIZE,TYPE,COUNTmust be kept.COUNTmay be left out (each field then has one element). A field whose count is below 1 is reported and removed from the cloud.WIDTHandHEIGHTmust be numbers. If neither is given, the cloud is unorganised withPOINTSpoints in one row. IfHEIGHTis missing it is 1 (with a warning) and a missingWIDTHbecomesPOINTS. AHEIGHTwithout aWIDTHis an error whenPOINTSis not zero.WIDTH×HEIGHTmust equalPOINTS, or the file is rejected.DATAis matched on its first letters:binary_compressed, thenbinary, thenascii. An unknown form is reported and the header reading goes on to the next line. The data starts immediately after theDATAline’s line feed. Only an unknown DATA form is skipped this way: the loopcontinues without setting the data position.
The PCL writer’s header begins # .PCD v0.7 - Point Cloud Data file
format, then VERSION 0.7, and always writes a
VIEWPOINT line. Its binary header marks gaps between fields as padding:
a field named _ with SIZE 1, TYPE U and a
COUNT equal to the gap in bytes. The ASCII writer and the binary_compressed reader and writer
leave a field named _ out of their data; the ASCII reader counts its
COUNT tokens per line but ignores their values; in plain
binary data the padding bytes are really present.
Data forms
| DATA | Layout |
|---|---|
ascii | One point per line, values separated by spaces or tabs in field order, all COUNT elements of a field in turn. NaN is written nan |
binary | The points one after another, each point’s fields in order, little-endian as written on x86 computers, with no separators |
binary_compressed | A uint32 compressed size, a uint32 uncompressed size, then the data compressed with Marc Lehmann’s LZF |
Before compressing, binary_compressed reorders the data from one point
after another into one field after another: all the x values, then all the y values,
and so on (xyzxyzxyz becomes xxxyyyzzz). A reader decompresses and then puts each
point back together.
In an organised cloud the points are stored row by row, WIDTH points per
row.
A binary file is rejected as corrupted if it is shorter than the header
plus POINTS × point size, and a binary_compressed file if it is
shorter than the header plus 8 plus the stored compressed size (pcd_io.cpp
lines 744-784). Bytes after the data are ignored.
binary_compressed details
- The reader checks that the stored uncompressed size equals
POINTS× the size of one point as the header describes it (the sum over the fields ofCOUNT×SIZE); any mismatch is treated as corruption. It then decompresses and rejects the block if the number of bytes produced differs from that size. - After decompression the data is field by field: for each field in header order,
the values of all points (
COUNTelements of the field, point after point) follow one another, then the next field. Padding fields (_) are not stored. The writer also leaves them out of the header, but the reader’s size check uses the point size from the header, which counts any_field, while its unpacking strides skip them; a compressed file whose header contains_is therefore not read consistently. - Because the two sizes are 32-bit, PCL’s writer refuses data for which
data size × 3 / 2exceeds 4,294,967,295 bytes (about 2.8 GB of points). The writer allocates 1.5 times the data size as the compression buffer and fails if the compressed data does not fit. With no points, both sizes are 0.
ascii details
- Blank lines are skipped. Each other line is split at spaces, tabs and carriage
returns and must have exactly as many words as the fields have elements in total
(the sum of all
COUNTs, padding included). A line with a different number of words is reported and still counts as a point: that point is left as zero bytes, and every later line goes into its own point as usual, so nothing shifts (readBodyASCIIinpcd_io.cpp). Lines beyondWIDTH×HEIGHTpoints (bad lines included in the count) are not read. - Reading stops after
WIDTH×HEIGHTpoints; if the file ends early the read fails. - The word
nan(any letter case) is a NaN and marks the cloud as not dense. Other words are read as numbers by the C++ stream; if that fails, the Catofconversion is used, which also understandsinfand-inf. Integers of 1 byte are read through anint. - The writer prints one point per line, values separated by one space; a NaN is
written
nan; 1-byte integers are printed as numbers, not characters; and anrgbfield is printed as an unsigned integer (see Colour).
NaN, Inf and is_dense
PCL’s cloud has an is_dense flag, true when no point has an invalid
(NaN or infinite) coordinate value. It is not stored in the file; the reader sets it:
true to begin with, and false when an ASCII word is nan, or, for binary
and binary_compressed data, when any floating-point element of any field
is not finite (NaN or ±Inf). Integer fields are always finite. An ASCII
inf does not clear the flag.
The LZF stream
binary_compressed uses Marc Lehmann’s LZF. PCL’s copy,
io/src/lzf.cpp, documents the compressed format in a comment, and
lzfDecompress shows how it is read. The stream is a series of items, each
starting with a control byte c:
| Control byte | Then | Meaning |
|---|---|---|
000LLLLL (below 0x20) | c + 1 bytes | Literal run: copy the next c + 1 bytes (1 to 32) to the output. |
LLLooooo with LLL from 1 to 6 | 1 byte, b | Back reference: length = LLL + 2 (3 to 8 bytes); distance = (ooooo × 256 + b) + 1 bytes back from the current output position. |
111ooooo (LLL = 7) | 2 bytes, e then b | Long back reference: length = 7 + e + 2 (9 to 264 bytes); distance = (ooooo × 256 + b) + 1. |
The distance is from 1 to 8192 (13 bits plus one), and the copy may overlap its own
output (distance smaller than length repeats the bytes just written), so it must be done
byte by byte. The decoder stops when the input is used up; it fails if the output would
exceed the expected size, a back reference points before the start of the output, or the
input ends in the middle of an item. The comment in lzf.cpp gives the
distance range as 1 to 4096 (o+1) and the literal run as up to 33, but the
code of both the compressor (off < 1 << 13, literals flushed at
32) and the decompressor uses the ranges above.
Example: 04 41 42 43 44 45 20 01 — a literal run of 5 bytes
ABCDE, then control 20 (length 1 + 2 = 3, high distance bits
0) with b = 01, distance 2: copy 3 bytes starting 2 back,
giving DED (the third byte comes from the byte just written), so the output
is ABCDEDED.
Field names in real files
The format itself allows any field names; these are the names PCL’s own point types
write (the third argument of POINT_CLOUD_REGISTER_POINT_STRUCT in
common/include/pcl/impl/point_types.hpp and
impl/feature_types.hpp, raw files read 2026-11-14). Types are those of the
C++ members; 8-byte integers and the B type are not used by these types.
| Field names (COUNT 1 unless shown) | Type | Point type |
|---|---|---|
x y z | float32 | PointXYZ and all the XYZ types |
x y; u v | float32 | PointXY; PointUV |
rgb | float32 | PointXYZRGB, PointXYZRGBNormal |
rgba | uint32 | RGB, PointXYZRGBA, PointXYZRGBL, PointSurfel |
intensity | float32 (uint8 in Intensity8u, uint32 in Intensity32u) | PointXYZI, PointXYZINormal, PointDEM, Intensity |
label | uint32 | PointXYZL, PointXYZRGBL, PointXYZLNormal, Label |
normal_x normal_y normal_z | float32 | Normal, Axis (no curvature), PointNormal, PointXYZRGBNormal, PointXYZINormal, PointXYZLNormal, PointSurfel |
curvature | float32 | every normal type above except Axis |
L a b; h s v | float32 | PointXYZLAB; PointXYZHSV |
strength; range; scale | float32 | InterestPoint; PointWithRange; PointWithScale |
vp_x vp_y vp_z; gradient_x gradient_y gradient_z | float32 | PointWithViewpoint; IntensityGradient |
radius confidence | float32 | PointSurfel |
intensity_variance height_variance | float32 | PointDEM |
fpfh (33), vfh (308), esf (640), grsd (21), pfh (125), pfhrgb (250), gfpfh (16), gasd (512, 984 or 7992) | float32 | feature histograms: FPFHSignature33, VFHSignature308, ESFSignature640, GRSDSignature21, PFHSignature125, PFHRGBSignature250, GFPFHSignature16, GASDSignature* |
shot (352 or 1344), shape_context (1980 or 1960), rf (9) | float32 | SHOT352, SHOT1344, ShapeContext1980, UniqueShapeContext1960 |
x_axis y_axis z_axis (3 each); values (12); descriptor (36) | float32 | ReferenceFrame; NormalBasedSignature12; Narf36 |
j1 j2 j3; r_min r_max; pc1 pc2, principal_curvature_x principal_curvature_y principal_curvature_z | float32 | MomentInvariants; PrincipalRadiiRSD; PrincipalCurvatures |
f1 f2 f3 f4 alpha_m (and f5–f10, r_ratio g_ratio b_ratio in the variants) | float32 | PPFSignature, CPPFSignature, PPFRGBSignature |
boundary_point | uint8 | Boundary |
brisk_scale brisk_orientation; brisk_descriptor512 (64) | float32; uint8 | BRISKSignature512 |
Other tools (sensor drivers, converters) add names that PCL’s point types do not
define. The PCL reader keeps whatever names the FIELDS line gives, and
the program that produces a file decides what such a name means; the header alone
gives its type, size and count. Names written by common sensor software
(declarations read raw from the projects’ source on GitHub, 2026-11-14):
| Field | Type | Meaning and source |
|---|---|---|
t | uint32 | Ouster ROS driver point ouster_ros::Point (os_point.h, ouster-ros ros2 branch); the source gives no comment on its meaning. LIO-SAM’s Ouster struct (imageProjection.cpp) declares it the same way |
reflectivity | uint16 | Ouster point, same struct |
ring | uint16 | Ouster point (“equivalent to channel”); also the Velodyne driver, LIO-SAM’s Velodyne struct and LeGO-LOAM’s PointXYZIR (utility.h). LIO-SAM’s Ouster struct declares it uint8 |
ambient | uint16 | Ouster point (“equivalent to near_ir”) |
range | uint32 | Ouster point; PCL’s own PointWithRange uses a float32 range, so the same name has two types |
intensity | float32 | Ouster point (“equivalent to signal”) and the Velodyne driver |
time | float32 | Velodyne driver (pointcloudXYZIRT.cc, ros-drivers/velodyne master branch, built with x y z intensity float32, ring uint16, time float32); LIO-SAM’s Velodyne struct. Per-point time as the consuming program defines it |
noise | uint16 | LIO-SAM’s Ouster struct only |
The Velodyne driver has no point_types.h: its fields are named in the
constructor of pointcloudXYZIRT.cc (and its header declares the iterators
as float for x y z intensity time and uint16_t for ring).
These drivers publish ROS point clouds; the table gives the type each declares, and a
PCD file written from them states its own type letter and size for each field.
Worked example
The header FIELDS x y z rgb, SIZE 4 4 4 4,
TYPE F F F U, DATA binary is followed by 16 bytes per
point:
| Bytes | Meaning |
|---|---|
00 00 80 3F | x = 1.0 |
00 00 00 40 | y = 2.0 |
00 00 00 00 | z = 0.0 |
00 80 FF 00 | rgb 0x00FF8000: red 255, green 128, blue 0 |