LASheader: Create a 'LASheader' object

View source: R/methods-LASheader.R

LASheaderR Documentation

Create a LASheader object

Description

Creates a LASheader object either from a raw list containing all the elements named according to the rlas package or creates a header from a data.frame or data.table containing a point cloud. In the latter case it will generate a header according to the data using rlas::header_create(). It will guess the LAS file format, the point data format, and initialize the scale factors and offsets, but these may not suit a user's needs. Users are advised to manually modify the results to fit their specific needs.

Usage

LASheader(data = list())

Arguments

data

a list containing the data from the header of a LAS file. Can also be a data.frame or data.table

Value

An object of class LASheader

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.28141, 269347.28142, 269347.28143),
                  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),
                  ScanAngleRank = c(-21L, -21L, -21L),
                  UserData = c(32L, 32L, 32L),
                  PointSourceID = c(17L, 17L, 17L))

header = LASheader(data)
header

# Record an EPSG code
epsg(header) <- 32618
header

las <- LAS(data, header)
las

# The function inferred a LAS 1.2 format 1 which is correct
# Upgrade to LAS 1.4 for the example
header@VLR <- list() # Erase VLR previously written
header@PHB[["Global Encoding"]][["WKT"]] <- TRUE
header@PHB[["Version Minor"]] <- 4L
header@PHB[["Header Size"]] <- 375L
header@PHB[["Offset to point data"]] <- 375L
wkt(header) <- sf::st_crs("EPSG:32618")$wkt
header
las1.4 <- LAS(data, header)
las1.4

lidR documentation built on Sept. 11, 2024, 5:21 p.m.