No organisation defines the XYZ point format; it is a convention. This page
describes what the files contain in practice and how widely used open source readers
treat them: Open3D (FileXYZ.cpp, FileXYZN.cpp,
FileXYZRGB.cpp), which skips any line that does not start with three
numbers, and PDAL’s text reader. Anything beyond these rules is
a choice of the program that wrote the file.
Lines
- Plain text, usually ASCII; one point per line, ending with LF or CR LF.
- Values are decimal numbers in the C form: a full stop as decimal separator, an
optional sign and an optional exponent (
1.5e-3). Files from programs set to a European locale sometimes use commas instead, which then cannot also be the separator. - Values are separated by spaces, tabs, commas or semicolons. Runs of spaces count as one separator.
- There is no point count and no end marker; the file ends with the last line.
- Units and coordinate system are not recorded. Survey files usually hold projected coordinates in metres (easting, northing, height); scanner exports often hold local coordinates.
Header lines
Most files have none. Some begin with a line naming the columns, such as
X,Y,Z; some programs start it with // so that it reads
as a comment. PDAL’s text reader requires
such a line: if it starts with a double quote, each name is quoted; otherwise the
first character that is not a letter or digit is the separator. Every following
line must have the same number of fields, and blank lines are skipped. The
example below uses PDAL’s dimension names.
Column layouts
The first three columns are always X, Y and Z. Readers recognise further columns by their count, by a header, or by asking the user.
| Columns | Layout | Notes |
|---|---|---|
| 3 | x y z | The basic form; Open3D’s .xyz |
| 4 | x y z i | With an intensity or a scalar value such as a classification |
| 6 | x y z r g b | Colour as integers 0–255, or as decimals 0–1 in Open3D’s .xyzrgb |
| 6 | x y z nx ny nz | With a unit normal; Open3D’s .xyzn |
| 7 | x y z i r g b | Intensity and colour, as in PTS |
| 9 | x y z r g b nx ny nz | Colour and normal; one common order, but not the only one |
A six-column file may hold either a colour or a normal; values all between −1
and 1 that form unit vectors suggest a normal, whole numbers up to 255 a colour.
Open3D settles it with the extension (.xyzn or
.xyzrgb), and writes each value with ten decimal places.
Gridded elevation
Elevation models exported as XYZ list one line per grid cell, in rows, with a constant spacing in X and Y. Nothing marks such a file as a grid; GIS programs detect the regular spacing when importing it as a raster.
Other formats with this extension
In chemistry, .xyz is a different format: a line with the number of
atoms, a comment line, then one line per atom with its element symbol and
coordinates in ångström. A first line holding a single whole number, followed by
lines starting with letters, marks that format rather than a point cloud.
Worked example
X Y Z Red Green Blue
1.250 0.500 2.000 200 30 30
1.252 0.501 2.004 198 31 29