Introduction
An XYZ file is the simplest way to store a point cloud: a text file with one point per line, written as its X, Y and Z coordinates. It is not a standard, just a convention, and it is used for scans, survey points, elevation grids and any other list of 3D points that needs to be read by many programs.
The extension .xyz is also used for other text formats, most notably for
molecule geometries in chemistry, which list an atom and its position on each line. That
is a separate format with its own page: XYZ molecule
geometry.
Structure
Each line holds the three coordinates, separated by spaces, tabs or commas. Many files add more columns after them, such as a colour as red, green and blue, an intensity or a normal, and some begin with a header line naming the columns. Since nothing in the file says which layout is used, programs that import XYZ files usually ask which column holds what.
512034.21 181220.75 12.40
512034.71 181220.75 12.43
512035.21 181220.75 12.47
In this reference
- Lines and columns – separators and numbers, header lines, the usual column layouts, gridded elevation, the chemistry format of the same name, and how Open3D and PDAL read them
Not described
Known, not yet covered
- Viewer: none yet; the site shows the hex viewer only.
- Reference: (NEW) CloudCompare’s ASCII reader (
AsciiFilter.cpp), the program the page names as the main one, is not described. Its rules: registered for.txt,.asc,.neu,.xyz,.ptsand.csv; empty lines and lines starting with//are ignored; each line is trimmed and runs of whitespace collapsed before it is split on the chosen separator; a line with too few parts, or a non-numeric X, Y or Z, is skipped with a warning; skipped-line count (empty lines not counted); optional comma as decimal separator; a file with lone CR line endings is read as LF; the column roles it offers (X, Y, Z, normal, red, green, blue, alpha as 0–255 or as 0–1 floats, packed 32-bit integer or float RGBA, grey, any number of scalar fields, quaternion w x y z, label); large files split into several clouds; its writer (8 decimals for coordinates, 6 for scalars, optional//X,Y,Z,…column-name line, optional point-count first line, chosen separator). Its dialog’s automatic guess of separator, header and column roles (AsciiOpenDlg.cpp) was not read, so it is unverified. - Reference: (NEW) Open3D rules the page omits: the reader takes only the first three (or six) numbers on a line and ignores any further columns, so a six-column
.xyzreads as plain points; its number test (sscanf %lf) also acceptsnan,infand hexadecimal floats; the format is chosen from the lower-case extension (xyz,xyzn,xyzrgb, pluspts) or an explicit format argument; the reader returns success even when no point was found;.xyznand.xyzrgbare not written at all when the cloud has no normals or no colours; the colours of.xyzrgbare read as given, with no scaling from 0–255; non-finite points are removed only when the caller asks. - Reference: (NEW) PDAL rules the page omits: how a column name becomes a dimension (standard dimension names such as X, Y, Z map to those dimensions, other names become new dimensions, all stored as double; the page does not say which names are standard, and PDAL’s dimension list was not read); the filename
STDINto read standard input; in a quoted header the separator is taken from the first gap only, a gap longer than one character is an error, and a name not followed by a closing quote is an error; only a completely empty line counts as blank, so a line of spaces, or a CR left by CR LF endings, is not skipped as blank and is handled as a data line (wrong field count, or a non-numeric last field). - Reference: (NEW) The other programs the page links, MeshLab and QGIS, are not described and their readers were not checked; neither are the sibling extensions
.asc,.txt,.neu,.xyzrgbaand how they relate to.xyz.
Unknown
- Reference: any rule beyond what the readers in PDAL and Open3D implement. XYZ has no specification: every program chooses its own columns, separators and header, so the page can describe common practice only.
Also used for
- XYZ molecule geometry – Atom positions of a molecule: a count, a comment, then one atom per line.
Links
Software
- CloudCompare – free open source point cloud and mesh tool that asks which column holds what (Windows, macOS, Linux)
- MeshLab – free open source mesh and point cloud viewer and editor (Windows, macOS, Linux)
- QGIS – free open source GIS that imports XYZ survey points (Windows, macOS, Linux)