lasaddattribute

0th

Percentile

Add attributes into a LAS object

A LAS object represents a .las file in R. According to the LAS specifications a las file contains a core of defined attributes, such as XYZ coordinates, intensity, return number, and so on for each point. It is possible to add supplementary attributes. The functions lasadd* enable the user to add new attributes (see details).

Usage
lasadddata(las, x, name)

lasaddextrabytes(las, x, name, desc)

lasaddextrabytes_manual(las, x, name, desc, type, offset = NULL, scale = NULL, NA_value = NULL)

lasremoveextrabytes(las, name)

Arguments
las

An object of class LAS

x

a vector that needs to be added in the LAS object. For lasaddextrabytes* it can be missing (see details).

name

character. The name of the extra bytes attribute to add in the file.

desc

character. A short description of the extra bytes attribute to add in the file (32 characters).

type

character. The data type of the extra bytes attribute. Can be "uchar", "char", "ushort", "short", "uint", "int", "uint64", "int64", "float", "double".

scale, offset

numeric. The scale and offset of the data. NULL if not relevant.

NA_value

numeric or integer. NA is not a valid value in a las file. At time of writing it will be replaced by this value that will be considered as NA. NULL if not relevant.

Details

Users cannot assign names that are the same as the names of the core attributes. These functions are dedicated to adding data not part of the LAS specification. For example, lasaddextrabytes(las, x, "R") will fail because R is a name reserved for the red channel of las file that contains RGB attributes. lasadddata simply adds a new column in the data but does not update the header. Thus the LAS object is not strictly valid. These data will be temporarily usable at the R level but will not be written in a las file with writeLAS. lasaddextrabytes does the same as lasadddata but automatically updates the header of the LAS object. Thus, the LAS object is valid and the new data is considered as "extra bytes". This new data will be written in a las file with writeLAS. lasaddextrabytes_manual allows the user to manually write all the extra bytes metadata. This function is reserved for experienced users with a good knowledge of the LAS specifications. The function does not perform tests to check the validity of the information. When using lasaddextrabytes and lasaddextrabytes_manual, x can only be of type numeric (integer or double). It cannot be of types character or logical as these are not supported by the las specifications. The types that are supported in lidR are types 0 to 10 (table 24 page 25 of the specification). Types greater than 10 are not supported.

Value

An object of class LAS

Aliases
  • lasaddattribute
  • lasadddata
  • lasaddextrabytes
  • lasaddextrabytes_manual
  • lasremoveextrabytes
Examples
# NOT RUN {
LASfile <- system.file("extdata", "example.laz", package="rlas")
las <- readLAS(LASfile, select = "xyz")

print(las)
print(las@header)

x <- 1:30

las <- lasadddata(las, x, "mydata")
print(las)        # The las object has a new attribute called "mydata"
print(las@header) # But the header has not been updated. This new data will not be written

las <- lasaddextrabytes(las, x, "mydata2", "A new data")
print(las)        # The las object has a new attribute called "mydata2"
print(las@header) # The header has been updated. This new data will be written

# Optionally if the data is already in the LAS object you can update the header skipping the
# parameter x
las <- lasaddextrabytes(las, name = "mydata", desc = "Amplitude")
print(las@header)

# Remove an extra bytes attribute
las <- lasremoveextrabytes(las, "mydata2")
print(las)
print(las@header)

las <- lasremoveextrabytes(las, "mydata")
print(las)
print(las@header)
# }
Documentation reproduced from package lidR, version 2.0.0, License: GPL-3

Community examples

Looks like there are no examples yet.