Please enable JavaScript to view this site.

TerraScan User Guide

Navigation: Programming Interface > File Formats > Point file formats

TerraScan binary files

Scroll Prev Top Next More

TerraScan binary files

The recommended format for processing point clouds in TerraScan is FastBinary. This format is not documented openly but information may be provided upon request.

The information below refers to file formats which were last revised on 12.07.2001 and on 15.07.2002. These version dates are stored in the file header. Future versions of TerraScan may store laser points into another format but will always recognize and read in the old files.

TerraScan reads and writes two versions of the old binary file format:

Scan binary 8 bit line - a more compact version which can accommodate line numbers 0-255. Files with this format have HdrVersion field set to 20010712.

Scan binary 16 bit line - a slightly bigger version which can accommodate line numbers 0-65535. Files with this format have HdrVersion field set to 20020715.

See \terra64\addon\routines.c for example source code for reading in TerraScan binary files.

File organization

TerraScan binary file consists of a file header of 48 bytes and a number of point records. The size of the point record is 16 bytes for file version 20010712 and 20 bytes for file version 20020715. Each point record may be followed by an optional four byte unsigned integer time stamp and an optional four byte RGB color value.

For example, a file containing four laser points and their time stamps using format 20020715 would consist of:

48 byte header (ScanHdr)

20 byte record for first point (ScanPnt)

4 byte time stamp for first point

20 byte record for second point (ScanPnt)

4 byte time stamp for second point

20 byte record for first three (ScanPnt)

4 byte time stamp for three point

Structure definitions

The structure of the file header is:

typedef struct {

int     HdrSize ;     // sizeof(ScanHdr)

int     HdrVersion ;  // Version 20020715, 20010712, 20010129 or 970404

int     RecogVal ;    // Always 970401

char    RecogStr[4];  // CXYZ

long    PntCnt ;      // Number of points stored

int     Units ;       // Units per meter = subpermast * uorpersub

double  OrgX ;        // Coordinate system origin

double  OrgY ;

double  OrgZ ;

int     Time ;        // 32 bit integer time stamps appended to points

int     Color ;       // Color values appended to points

} ScanHdr ;

The structure of a point record for file version 20010712 is:

typedef struct {

BYTE    Code ;        // Classification code 0-255

BYTE    Line ;        // Line number 0-255

USHORT  EchoInt ;     // Intensity bits 0-13, echo bits 14-15

long    X ;           // Easting

long    Y ;           // Northing

long    Z ;           // Elevation

} ScanRow ;

The structure of a point record for file version 20020715 is:

typedef struct {

Point3d Pnt ;         // Coordinates

BYTE    Code ;        // Classification code

BYTE    Echo ;        // Echo information

BYTE    Flag ;        // Runtime flag (view visibility)

BYTE  Mark ;          // Runtime flag

USHORT  Line ;        // Line number

USHORT  Intensity ;   // Intensity value

} ScanPnt ;

Coordinate system

Laser point coordinates are stored as integer values which are relative to an origin point stored in the header. To compute user coordinate values X, Y and Z (normally meters), use:

X = (Pnt.X - Hdr.OrgX) / (double) Hdr.Units ;

Y = (Pnt.Y - Hdr.OrgY) / (double) Hdr.Units ;

Z = (Pnt.Z - Hdr.OrgZ) / (double) Hdr.Units ;

Time stamps

Time stamps are assumed to be GPS week seconds. The storage format is a 32 bit unsigned integer where each integer step is 0.0002 seconds.

Echo information

TerraScan uses two bits for storing echo information. The possible values are:

0 Only echo

1 First of many echo

2 Intermediate echo

3 Last of many echo

TerraScan User Guide   01.01.2024   © 2024 Terrasolid Ltd