View source: R/add_attribute.R
add_attribute | R Documentation |
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.
add_attribute(las, x, name)
add_lasattribute(las, x, name, desc)
add_lasattribute_manual(
las,
x,
name,
desc,
type,
offset = NULL,
scale = NULL,
NA_value = NULL
)
add_lasrgb(las, R, G, B)
add_lasnir(las, NIR)
remove_lasattribute(las, name)
las |
An object of class LAS |
x |
a vector that needs to be added in the LAS object. For |
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. |
R , G , B , NIR |
integer. RGB and NIR values. Values are automatically scaled to 16 bits if they are coded on 8 bits (0 to 255). |
Users cannot assign names that are the same as the names of the core attributes. These functions are
dedicated to adding data that are not part of the LAS specification. For example, add_lasattribute(las, x, "R")
will fail because R
is a name reserved for the red channel of a .las file that contains RGB
attributes. Use add_lasrgb
instead.
add_attribute
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.
add_lasattribute
Does the same as add_attribute
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.
add_lasattribute_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 add_lasattribute
and add_lasattribute_manual
, x
can only be of type numeric,
(integer
or double
). It cannot be of type 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 on page 25 of the specification). Types greater than 10 are not supported.
add_lasrgb
Adds 3 columns named RGB and updates the point format of the LAS object for a format that supports RGB attributes. If the RGB values are ranging from 0 to 255 they are automatically scaled on 16 bits.
An object of class LAS
LASfile <- system.file("extdata", "example.laz", package="rlas")
las <- readLAS(LASfile, select = "xyz")
print(las)
print(header(las))
x <- 1:30
las <- add_attribute(las, x, "mydata")
print(las) # The las object has a new attribute called "mydata"
print(header(las)) # But the header has not been updated. This new data will not be written
las <- add_lasattribute(las, x, "mydata2", "A new data")
print(las) # The las object has a new attribute called "mydata2"
print(header(las)) # 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 <- add_attribute(las, x, "newattr")
las <- add_lasattribute(las, name = "newattr", desc = "Amplitude")
print(header(las))
# Remove an extra bytes attribute
las <- remove_lasattribute(las, "mydata2")
print(las)
print(header(las))
las <- remove_lasattribute(las, "mydata")
print(las)
print(header(las))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.