class

Lidar::LasFile

Inherits Reference < Object

The main class for dealing with a LAS file data structure.

Constructors

new(file_name : String, header : LasHeader, vlr_data : Array(VLR), record_data : Array(PointData))

Creates a new LasFile for writing to disc based on a file_name, header, vlr_data, and record_data. The file_mode parameter will be set to "w" for write-access.

file_name = a String containing the name of the file.

header = a LasHeader struct used to initialize the file properties.

vlr_data = an array of VLR structs containing each of the variable length records.

record_data = an array of PointData structs containing the point data.

See also: methods add_header, add_vlr, and add_point_record, which can be used to add these components individually and after initialization using the standard initialize method in "w" file_mode.

Source
new(file_name : String, file_mode = "r")

Creates a LasFile based on a file_name. The file_mode parameter must equal "r" for read-only, or "w" for write.

Example

file_name = "/path/to/file/data.las"
lf1 = Lidar::LasFile.new file_name, "r"
puts("#{lf1.to_s}") # => prints file header info
puts("#{lf1[100]}") # => prints the 100th point record

new_file = "/path/to/file/newFile.las"
lf2 = Lidar::LasFile.new new_file, "w"
# Add the header
lf2.add_header(lf1.header)
# Add the VLRs to the file
lf1.vlr_data.each do |vlr|
  lf2.add_vlr(vlr)
end

# Add the point data to the file
(0...lf1.header.number_of_points).each do |i|
  lf2.add_point_record(lf1[i])
end

lf2.write
Source

Instance methods

[](point_num : Int)

Returns the full point record for a specifed point_num.

Source
add_header(header : LasHeader)

Sets the properties of the LAS file using a specified LasHeader struct.

Source
add_point_record(p : PointRecord0 | PointRecord1 | PointRecord2 | PointRecord3)

Adds a point record (either type 0, 1, 2, or 3) to this LAS file.

Source
add_vlr(vlr : VLR)

Adds a variable length record (VLR) to this LAS file.

Source
file_name

returns the file name and full path of this LasFile.

Source
get_version

Returns a string containing the LAS version number of this file.

Source
get_xyz_data(point_num : Int)

Returns the X,Y,Z data for a specified point_num.

Source
get_xyzi_data(point_num : Int)

Returns the X,Y,Z, and intensity data for a specified point_num.

Source
header

Gets and sets the LasHeader associated with this LasFile.

Source
header=(header : Lidar::LasHeader)

Gets and sets the LasHeader associated with this LasFile.

Source
read

Reads the header, variable length records (VLRs), and point data of the LAS file.

Source
size

Returns the size of the LAS file in megabytes.

Source
to_s(io)

Returns a string represenation of the LAS file properties.

Source
vlr_data

Gets and sets the variable length record (VLR) array associated with this LasFile.

Source
vlr_data=(vlr_data : Array(Lidar::VLR))

Gets and sets the variable length record (VLR) array associated with this LasFile.

Source
write

Writes the header, variable length records (VLRs), and point data of the LAS file to disc.

Source