Skip to content
LidarKit

What is a PCD file?

The point cloud format of the Point Cloud Library — and with it, of robots, ROS and SLAM maps.

Published

A PCD file (Point Cloud Data) is the native file format of the Point Cloud Library, PCL. A short text header says what each point holds and how the points are stored; the points follow, as text or as binary. Here is the start of one, a city block saved by Open3D:

# .PCD v0.7 - Point Cloud Data file format
VERSION 0.7
FIELDS x y z rgb
SIZE 4 4 4 4
TYPE F F F F
COUNT 1 1 1 1
WIDTH 158098
HEIGHT 1
VIEWPOINT 0 0 0 1 0 0 0
POINTS 158098
DATA ascii
149.1999969 12.68000031 42.38000107 1.30935689e-38
145.8600006 13.02000046 56.84000015 1.751679833e-38

Two things in those last lines are worth a second look. The first coordinate was 149.2 before it was saved: stored as a 32-bit float it becomes 149.1999969, and printed in full that is what appears. And the fourth number, 1.3 × 10-38, is a colour — red 142, green 147, blue 139 — packed into the bits of a float, which the section on colour below explains.

3D view of a city block point cloud in its surveyed colours, read from a PCD file
The same block as a binary_compressed PCD, 158,098 points with packed colour, open in the PCD viewer.

Where PCD files come from

  • PCL itself. Any program built on PCL saves and loads clouds with pcl::io::savePCDFile and loadPCDFile.
  • ROS. The pcl_ros package has tools that write point cloud messages from a running robot or a recorded bag to PCD files.
  • SLAM. LiDAR SLAM packages such as LIO-SAM and FAST-LIO save the maps they build as PCD.
  • Depth cameras. Kinect, RealSense and similar cameras, captured through PCL or ROS, give organized PCD frames.
  • General tools. Open3D and PDAL read and write PCD, so it also turns up as an exchange format between them.

The header, line by line

The keywords come in this order in files PCL writes. Older files (versions 0.5 and 0.6) leave some out, and readers fill those in with PCL's defaults.

KeywordWhat it says
VERSIONThe format version, 0.7 for everything written in the last decade.
FIELDSThe name of each field: x y z, rgb, intensity, normal_x, and so on. PCL's padding bytes appear as _.
SIZEBytes per value for each field: 1, 2, 4 or 8.
TYPEF for floating point, I for signed and U for unsigned integers.
COUNTValues per field, usually 1. Descriptors such as a 33-bin FPFH histogram have more. Defaults to 1.
WIDTH, HEIGHTThe shape of the cloud. HEIGHT 1 is an unorganized list; anything more is a grid, row by row.
VIEWPOINTWhere the sensor was: a position, then an orientation as a quaternion (w x y z). Defaults to 0 0 0 1 0 0 0.
POINTSThe number of points, WIDTH × HEIGHT.
DATAHow the points are stored: ascii, binary or binary_compressed.

Three ways to store the points

The same 158,098 points with colour, measured in each encoding, with the LAZ file the block was cut from for comparison:

Stored asSizeBytes per point
PCD, ascii8.06 MB51
PCD, binary2.53 MB16
PCD, binary_compressed2.04 MB13
LAZ, with intensity, returns, classification and GPS time too1.38 MB9
  • ascii is one point per line, values separated by spaces. Easy to inspect, slow to read, and several times the size of the binary forms. Missing points are written as nan.
  • binary is the points as fixed-size records, one after another, exactly as they sat in PCL's memory — including padding, which is what the _ fields in some headers account for. Values are in the byte order of the machine that wrote them, which in practice is always little-endian.
  • binary_compressed starts with two 4-byte numbers, the compressed and uncompressed sizes, then one LZF-compressed block. Before compressing, PCL regroups the values field by field — every x, then every y, then every z — because values of the same kind side by side compress far better than mixed records. Padding is left out.

The compressed form has a cost for readers: it cannot be sliced. Record one million of a binary file is at a computable offset; in a compressed file it is somewhere in an LZF stream that has to be decoded from the start, and its x, y and z are in three different places.

Organized clouds

When HEIGHT is more than 1, the cloud is organized: a grid of WIDTH × HEIGHT points that keeps the layout of the sensor. A Kinect frame is 640 × 480, one point per depth pixel; a spinning LiDAR's scan can be stored as beams × firings. Algorithms use the grid to find neighbours without a search.

Every slot is kept, including the pixels where the sensor saw nothing, and those hold NaN coordinates. In four Kinect frames of an office, 640 × 480 each, between 15 and 37 per cent of the 307,200 points are NaN. A reader has to leave them out, or it draws a cluster of points at the origin.

Organized clouds from cameras also come in the camera's optical frame: X to the right, Y down, Z straight ahead. A viewer that assumes Z is up shows the room lying on its back.

Colour, packed into a float

PCL's point types with colour store it in one four-byte field, rgb, with red, green and blue in the low three bytes and alpha, in rgba, in the top one. The field is usually declared TYPE F, a float — so its value as a number means nothing, and a reader has to take its bits. In a text file there are two ways to print those bits:

  • as the float, the way Open3D and older PCL do: 1.30935689e-38;
  • as an unsigned integer, the way current PCL does: 4287533963. PCL switched because with the alpha byte set, many colours are NaN as floats and would be lost in text.

Not every writer packs. PDAL writes red green blue as separate 8-byte floats holding 16-bit LAS colour; other tools write r g b as 0–1 floats or 0–255 integers. The header gives only the storage type, so the scale has to be found from the values themselves.

What a PCD file does not hold

  • Units and a coordinate system. There is no field for either. Robotics data is in metres by ROS convention and in a local frame — the sensor's, the robot's or the map's — not in a projection.
  • Precision to spare. Coordinates are almost always 32-bit floats. Near the origin that is far finer than any sensor; at 150 km from it, the gap between neighbouring float values is about 1.6 cm. Survey coordinates therefore do not belong in a float PCD without being shifted first.
  • A transform from the viewpoint. VIEWPOINT records where the sensor was. PCL does not move the points by it, and a reader should not either unless it knows the points were saved in the sensor's own coordinates.
  • Standard meanings. A field called label or intensity means what the writer meant; nothing defines its range. Compare LAS classification codes, which are fixed by the specification.

Not to be confused with Photo CD

Kodak's Photo CD, from the 1990s, stored scanned photographs as .pcd files too, several resolutions of one image in each. They have nothing in common with point clouds but the extension. A point cloud PCD shows readable keywords — VERSION, FIELDS — in a text editor; a Photo CD image has no such header, only binary image data.

Working with a PCD file here

Open it in the PCD viewer — ASCII, binary and binary_compressed, organized clouds with their NaN pixels left out and counted, packed colour in either text form, and an Up control for camera frames. The panel lists every field in the header with what it was used for. It runs in the browser and nothing is uploaded.

For the neighbouring formats, what is a LAS file covers the survey side, and what is an XYZ file the plain-text one. PLY, the other header-plus-records format, opens in the PLY viewer.

Frequently asked questions

What is a PCD file?
A point cloud in the format of the Point Cloud Library (PCL): a short text header naming the fields each point holds — x, y, z, colour, intensity, normals — followed by the points as text, as packed binary records, or as LZF-compressed binary. It is the usual way robots, ROS tools and SLAM packages save point clouds to disk.
How do I open a PCD file?
Drop it on the PCD viewer on this site. It reads ASCII, binary and binary_compressed files in the browser, draws the points in 3D, and lists every field in the header with what it was used for. Nothing is installed and nothing is uploaded.
Is every .pcd file a point cloud?
No. Kodak's Photo CD format used the same extension for scanned photographs in the 1990s. A point cloud PCD starts with readable text — a line beginning VERSION or FIELDS within the first few lines — while a Photo CD image has no such header. Opening the file in a text editor tells you which you have in a second.
What is the difference between binary and binary_compressed?
binary writes each point as one fixed-size record, every field side by side, exactly as it sat in PCL's memory. binary_compressed regroups the values field by field — every x, then every y — and compresses the result with LZF. Measured on a 158,098-point city block with colour, binary took 2.53 MB and binary_compressed 2.04 MB; ASCII took 8.06 MB.
What is an organized point cloud?
One whose points keep the grid of the sensor that captured them: HEIGHT is more than 1, and WIDTH × HEIGHT points are stored row by row like the pixels of an image. A Kinect frame is 640 × 480. Pixels where the sensor got no return are kept as NaN so that the grid stays whole, which is why an organized cloud can hold far fewer real points than its POINTS line says.
What units and coordinate system does a PCD file use?
The file does not say. PCD has no field for either. ROS uses metres by convention, so clouds from robots and SLAM maps are almost always in metres, in the frame of the sensor or the map. A depth-camera frame is usually in the camera's own optical frame: X to the right, Y down, Z straight ahead.
How is PCD different from PLY?
Both are a text header followed by records, as text or binary. PCD adds what point clouds from sensors need: an organized width × height layout, a sensor viewpoint, and LZF compression. PLY adds what meshes need: faces, and any number of named elements. PLY property names are a free-for-all; PCD field names follow PCL's point types closely enough to be read reliably.
How is PCD different from LAS?
LAS is the survey format: coordinates are integers with a stated scale and offset, the coordinate system is written into the file, and fields such as classification have meanings fixed by a specification. PCD is the robotics format: coordinates are usually 32-bit floats in a local frame, there is no coordinate system, and the fields are whatever the point type had. A float32 coordinate is good to a fraction of a millimetre near the origin but only to about 1.6 cm at 150 km from it, which is one reason PCD data stays in local frames.