Package Rlas': June 2, 2020
Package Rlas': June 2, 2020
Package Rlas': June 2, 2020
June 2, 2020
Type Package
Title Read and Write 'las' and 'laz' Binary File Formats Used for
Remote Sensing Data
Version 1.3.6
Date 2020-05-25
Description Read and write 'las' and 'laz' binary file formats. The LAS file format is a public file for-
mat for the interchange of 3-dimensional point cloud data between data users. The LAS specifi-
cations are approved by the American Society for Photogrammetry and Remote Sens-
ing <https://www.asprs.org/divisions-committees/lidar-division/laser-las-file-format-exchange-
activities>. The LAZ file format is an open and lossless compression scheme for binary LAS for-
mat versions 1.0 to 1.3 <https://laszip.org/>.
URL https://github.com/Jean-Romain/rlas
BugReports https://github.com/Jean-Romain/rlas/issues
License GPL-3
Depends R (>= 3.0.0)
Imports Rcpp, data.table
LazyData true
RoxygenNote 7.1.0
LinkingTo Rcpp,BH
Suggests testthat (>= 2.1.0), covr
Encoding UTF-8
NeedsCompilation yes
Author Jean-Romain Roussel [aut, cre, cph],
Florian De Boissieu [aut, ctb] (Enable the support of .lax file and
extra byte attributes),
Martin Isenburg [cph] (Is the author of the LASlib and LASzip
libraries),
David Auty [ctb] (Reviewed the documentation),
Pierrick Marie [ctb] (Helped to compile LASlib code in R),
Tiago de Conto [ctb] (Implemented the -thin_with_voxel filter method)
1
2 check_las_validity
R topics documented:
check_las_validity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
crs_tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
extra_bytes_attribute_tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
las_specification_tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
public_header_block_tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
read.las . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
read.lasheader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
write.las . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
writelax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Index 13
Description
las files are normalized files. These functions perform tests of compliance with LAS specification.
• check_las_validity tests if the data and the header contain information that cannot be writ-
ten into a las file. For example it tests is the intensities do not exeed 65535. It throws an error
for each deviance to the specification. It is useful for testing if modified R objects are still
valid.
• check_las_compliance test if the data and the header contain information that can be written
into a las file but are invalid with repect of the specification. For example it test if the RGB
colors are recoded on 16 bits. It is possible to store colors recorded on 8 bits (0 to 255) but it
is not correct to do that. It throws a warning for each deviance to the specification. It is useful
for testing if the data read from a file are correct.
Usage
check_las_validity(header, data)
check_las_compliance(header, data)
Arguments
header a list containing the header of a las file
data a data.frame or a data.table containing a point cloud
crs_tools 3
Description
Functions that update a header to describe coordinates reference system according to the LAS spec-
ifications
Usage
header_get_epsg(header)
header_set_epsg(header, epsg)
header_get_wktcs(header)
header_set_wktcs(header, WKT)
Arguments
header list
epsg integer. An EPSG code
WKT string. A string of an WKT OGC CS
See Also
Other header_tools: extra_bytes_attribute_tools, public_header_block_tools
extra_bytes_attribute_tools
Extra Bytes Attributes Tools
Description
Functions that update a header to describe Extra Bytes Attributes according to the LAS specifica-
tions
Usage
header_add_extrabytes(header, data, name, desc)
header_add_extrabytes_manual(
header,
name,
desc,
4 extra_bytes_attribute_tools
type,
offset = NULL,
scale = NULL,
max = NULL,
min = NULL,
NA_value = NULL
)
Arguments
header list
data vector. Data that must be added in the extrabytes attributes.
name character. The name of the extrabytes attributes to add in the file.
desc character. The description of the extrabytes attributes to add in the file.
type integer. The data type of the extrabytes attributes (page 25 of the spec).
scale, offset numeric. The scale and offset of the data. NULL if not relevant.
min, max numeric or integer. The minimum and maximum value of the data. NULL if not
relevant.
NA_value numeric or integer. NA is not a valid value. At writing time it will be replaced
by this value that will be considered as NA. NULL if not relevant.
See Also
Other header_tools: crs_tools, public_header_block_tools
Examples
data = data.frame(X = c(339002.889, 339002.983, 339002.918),
Y = c(5248000.515, 5248000.478, 5248000.318),
Z = c(975.589, 974.778, 974.471),
gpstime = c(269347.281418006, 269347.281428006, 269347.281438006),
Intensity = c(82L, 54L, 27L),
ReturnNumber = c(1L, 1L, 2L),
NumberOfReturns = c(1L, 1L, 2L),
ScanDirectionFlag = c(1L, 1L, 1L),
EdgeOfFlightline = c(1L, 0L, 0L),
Classification = c(1L, 1L, 1L),
ScanAngle = c(-21L, -21L, -21L),
UserData = c(32L, 32L, 32L),
PointSourceID = c(17L, 17L, 17L),
treeID = c(1L, 1L, 1L))
lasheader = header_create(data)
lasheader[["Variable Length Records"]]
las_specification_tools
A set of function to test conformance with LAS specifications
Description
Tools reserved to developpers and not intended to be used by regular users. The functions return
TRUE or FALSE by default without more information. If behavior is ’warning’ functions throw
a warning for each fail and return FALSE if any warning TRUE otherwise. If behavior is ’stop’
functions throw an error for the first fail and return TRUE if 0 error. If behavior is ’vector’ returns
a character vector with the decription of each error an never fail. Is it useful to make a detailed
inspection.
Usage
is_defined_offsets(header, behavior = "bool")
is_valid_filesourceid(header, behavior)
is_number_of_points_by_return_in_accordance_with_header(
header,
data,
behavior = "bool"
)
Arguments
public_header_block_tools
Public Header Block Tools
8 public_header_block_tools
Description
Create or update a header for a las file from a dataset. A las file consists of two parts. A header
that describes the data and the data itself. These functions make valid headers (public header block
only) that can be used in write.las.
Usage
header_create(data)
header_update(header, data)
Arguments
data data.frame or data.table
header list. A header
Details
header_create makes a full header from data. header_update modifies the information that needs
to be updated. But most of the original information is not modified, for example point data format
is kept ’as is’.
Value
A list containing the metadata required to write a las file.
See Also
Other header_tools: crs_tools, extra_bytes_attribute_tools
Examples
lasdata = data.frame(X = c(339002.889, 339002.983, 339002.918),
Y = c(5248000.515, 5248000.478, 5248000.318),
Z = c(975.589, 974.778, 974.471),
gpstime = c(269347.281418006, 269347.281428006, 269347.281438006),
Intensity = c(82L, 54L, 27L),
ReturnNumber = c(1L, 1L, 2L),
NumberOfReturns = c(1L, 1L, 2L),
ScanDirectionFlag = c(1L, 1L, 1L),
EdgeOfFlightline = c(1L, 0L, 0L),
Classification = c(1L, 1L, 1L),
ScanAngle = c(-21L, -21L, -21L),
UserData = c(32L, 32L, 32L),
PointSourceID = c(17L, 17L, 17L),
treeID = c(1L, 1L, 1L))
lasheader = header_create(lasdata)
read.las 9
Description
Reads data from .las or .laz files in format 1 to 4 according to LAS specifications and returns a
data.table labeled according to LAS specifications. See the ASPRS documentation for the LAS
file format. The optional parameters enable the user to save memory by choosing to load only the
fields they need. Moreover, the function provides a streaming filter to load only the points of interest
into the memory and hence avoids allocating any superfluous memory.
Usage
read.las(files, select = "*", filter = "", transform = "")
Arguments
files array of characters
select character. select only columns of interest to save memory (see details)
filter character. streaming filters - filter data while reading the file (see details)
transform character. streaming transformation - transform data while reading the file (see
details)
Details
Select: the ’select’ argument specifies the data that will actually be loaded. For example, ’xyzia’
means that the x, y, and z coordinates, the intensity and the scan angle will be loaded. The sup-
ported entries are t - gpstime, a - scan angle, i - intensity, n - number of returns, r - return number, c
- classification, s - synthetic flag, k - keypoint flag, w - withheld flag, o - overlap flag (format 6+) u
- user data, p - point source ID, e - edge of flight line flag, d - direction of scan flag, R - red channel
of RGB color, G - green channel of RGB color, B - blue channel of RGB color, N - near-infrared
channel. C - scanner channel (format 6+). Also numbers from 1 to 9 for the extra bytes data num-
bers 1 to 9. 0 enables all extra bytes to be loaded and ’*’ is the wildcard that enables everything to
be loaded from the LAS file.
Note that x, y, z are implicit and always loaded. ’xyzia’ is equivalent to ’ia’.
Filter: the ’filter’ argument allows filtering of the point cloud while reading files. rlas relies
on the well-known LASlib library written by Martin Isenburg to read the binary files. Thus the
package inherits the filter commands available in LAStools. To use these filters the user can pass
the common commands from LAStools into the parameter 'filter'. Type read.las(filter =
"-help") to display the LASlib documentation and the available filters.
Transform: the ’transform’ argument allows transformation of the point cloud while reading files.
rlas relies on the well-known LASlib library written by Martin Isenburg to read the binary files.
Thus the package inherits the tranform commands available in LAStools. To use these transforma-
tions the user can pass the common commands from LAStools into the parameter 'transform'.
10 read.lasheader
Type read.las(transform = "-help") to display the LASlib documentation and the available
transformations
Value
A data.table
Examples
lazfile <- system.file("extdata", "example.laz", package="rlas")
Description
Reads header from .las or .laz files in format 1 to 4 according to LAS specifications and returns
a list labeled according to LAS specifications. See the ASPRS documentation for the LAS file
format.
Usage
read.lasheader(file)
Arguments
file filepath character string to the .las or .laz file
Value
A list
See Also
Other rlas: write.las()
Examples
lazfile <- system.file("extdata", "example.laz", package="rlas")
lasheader <- read.lasheader(lazfile)
write.las 11
Description
Write a .las or .laz file. The user provides a table with the data in columns. Column names must
respect the specified allowed names (see details). A correct and complete header must also be
provided. This header can optionally be generated with header_create.
Usage
write.las(file, header, data)
Arguments
file character. file path to .las or .laz file
header list. Can be partially recycled from another file (see read.lasheader) and updated
with header_update or generated with header_create.
data data.frame or data.table that contains the data to write in the file. Column names
must respect the imposed nomenclature (see details)
Details
Allowed names are "X", "Y", "Z", "gpstime", "Intensity", "ReturnNumber", "NumberOfReturns",
"ScanDirectionFlag", "EdgeOfFlightline", "Classification", "ScanAngle", "UserData", "PointSour-
ceID", "R", "G", "B", "NIR". All other extra columns will be written in extra bytes attributes only
if the header specifically states these data should be saved into extra bytes attributes. To use the
full potential of the function write.las it is recommended users read the complete specifications
of the LAS file format. Otherwise users can rely on automated procedures that are expected to be
sufficient for most usages.
Value
void
See Also
Other rlas: read.lasheader()
Examples
lasdata = data.frame(X = c(339002.889, 339002.983, 339002.918),
Y = c(5248000.515, 5248000.478, 5248000.318),
Z = c(975.589, 974.778, 974.471),
gpstime = c(269347.281418006, 269347.281428006, 269347.281438006),
Intensity = c(82L, 54L, 27L),
ReturnNumber = c(1L, 1L, 2L),
NumberOfReturns = c(1L, 1L, 2L),
12 writelax
lasheader = header_create(lasdata)
file = file.path(tempdir(), "temp.laz")
Description
Write a lax file from a las or laz file. A lax file is a tiny file which can come with a las or laz
and which spatially index the data to make faster spatial queries. It has been invented by Martin
Isenburg in LASlib. rlas support lax file and enable to write a lax file with default settings. For more
options, use lasindex from binaries provided by LASlib (for more informations see references)
Usage
writelax(file, verbose = FALSE)
Arguments
file character. filename of .las or .laz file
verbose boolean. Verbose switch.
References
https://rapidlasso.com/
https://rapidlasso.com/2012/12/03/lasindex-spatial-indexing-of-lidar-data/
https://github.com/LAStools/LAStools
Index
check_las_compliance is_defined_extrabytes
(check_las_validity), 2 (las_specification_tools), 5
check_las_validity, 2 is_defined_filesourceid
crs_tools, 3, 4, 8 (las_specification_tools), 5
is_defined_globalencoding
extra_bytes_attribute_tools, 3, 3, 8 (las_specification_tools), 5
is_defined_offsets
header_add_extrabytes (las_specification_tools), 5
(extra_bytes_attribute_tools), is_defined_pointformat
3 (las_specification_tools), 5
header_add_extrabytes_manual is_defined_scalefactors
(extra_bytes_attribute_tools), (las_specification_tools), 5
3 is_defined_version
header_create, 11 (las_specification_tools), 5
header_create
is_empty_point_cloud
(public_header_block_tools), 7
(las_specification_tools), 5
header_get_epsg (crs_tools), 3
is_extrabytes_in_accordance_with_data
header_get_wktcs (crs_tools), 3
(las_specification_tools), 5
header_set_epsg (crs_tools), 3
is_gpstime_in_valid_format
header_set_wktcs (crs_tools), 3
(las_specification_tools), 5
header_update, 11
is_NIR_in_valid_format
header_update
(las_specification_tools), 5
(public_header_block_tools), 7
is_number_of_points_by_return_in_accordance_with_header
is_compliant_NumberOfReturns (las_specification_tools), 5
(las_specification_tools), 5 is_number_of_points_in_accordance_with_header
is_compliant_ReturnNumber (las_specification_tools), 5
(las_specification_tools), 5 is_RGB_in_valid_format
is_compliant_ReturnNumber_vs_NumberOfReturns (las_specification_tools), 5
(las_specification_tools), 5 is_ScanAngle_in_valid_format
is_compliant_RGB (las_specification_tools), 5
(las_specification_tools), 5 is_ScannerChannel_in_valid_format
is_compliant_ScanAngle (las_specification_tools), 5
(las_specification_tools), 5 is_valid_Classification
is_compliant_ScanAngleRank (las_specification_tools), 5
(las_specification_tools), 5 is_valid_date
is_defined_coordinates (las_specification_tools), 5
(las_specification_tools), 5 is_valid_EdgeOfFlightline
is_defined_date (las_specification_tools), 5
(las_specification_tools), 5 is_valid_extrabytes
13
14 INDEX
(las_specification_tools), 5 (las_specification_tools), 5
is_valid_filesourceid is_XY_smaller_than_bbox
(las_specification_tools), 5 (las_specification_tools), 5
is_valid_globalencoding is_Z_in_bbox (las_specification_tools),
(las_specification_tools), 5 5
is_valid_gpstime
(las_specification_tools), 5 las_specification_tools, 5
is_valid_Intensity
public_header_block_tools, 3, 4, 7
(las_specification_tools), 5
is_valid_KeypointFlag read.las, 9
(las_specification_tools), 5 read.lasheader, 10, 11
is_valid_NIR (las_specification_tools),
5 write.las, 8, 10, 11
is_valid_NumberOfReturns writelax, 12
(las_specification_tools), 5
is_valid_offsets
(las_specification_tools), 5
is_valid_OverlapFlag
(las_specification_tools), 5
is_valid_pointformat
(las_specification_tools), 5
is_valid_PointSourceID
(las_specification_tools), 5
is_valid_ReturnNumber
(las_specification_tools), 5
is_valid_RGB (las_specification_tools),
5
is_valid_scalefactors
(las_specification_tools), 5
is_valid_ScanAngle
(las_specification_tools), 5
is_valid_ScanAngleRank
(las_specification_tools), 5
is_valid_ScanDirectionFlag
(las_specification_tools), 5
is_valid_ScannerChannel
(las_specification_tools), 5
is_valid_SyntheticFlag
(las_specification_tools), 5
is_valid_UserData
(las_specification_tools), 5
is_valid_version
(las_specification_tools), 5
is_valid_WithheldFlag
(las_specification_tools), 5
is_valid_XYZ (las_specification_tools),
5
is_XY_larger_than_bbox