Base

Base Module Basics:

Most of the functionality of laspy is exposed on the file and header modules, however it will sometimes be convenient to dig into the base as well. The two workhorses of the base class are Writer and Reader, and they are both subclasses of FileManager, which handles a lot of the file initialization logic, as well as file reading capability.

class laspy.base.FileManager(filename, mode, header=False, vlrs=False, evlrs=False)[source]

Superclass of Reader and Writer, provides most of the data manipulation functionality in laspy.

__init__(filename, mode, header=False, vlrs=False, evlrs=False)[source]

Build the FileManager object. This is done when opening the file as well as upon completion of file modification actions like changing the header padding.

class laspy.base.Reader(filename, mode, header=False, vlrs=False, evlrs=False)[source]

Just a subclass of FileManager

close()

Help the garbage collector by deleting some of the circular references

get_dimension(name)

Grab a point dimension by name, returning a numpy array. Refers to reader.point_format for the required Spec instance.

get_header(file_version=1.2)

Return the header object, or create one if absent.

get_header_property(name)

Wrapper for grabbing unpacked header data with _get_datum

get_padding()

Return the padding between the end of the VLRs and the beginning of the point records

get_point(index, nice=False)

Return point object for point of number index / #legacy_api

get_pointrecordscount()

calculate the number of point records

get_points()

Return a numpy array of all point data in a file.

get_raw_point(index)

Return the raw bytestring associated with point of number index

get_vlrs()

Populate and return list of laspy.header.VLR objects`.

populate_vlrs()

Catalogue the variable length records

class laspy.base.Writer(filename, mode, header=False, vlrs=False, evlrs=False)[source]
_set_datum(rec_offs, dim, val)[source]

Set a non dimension field as with _set_raw_datum, but supply a formatted value

close(ignore_header_changes=False, minmax_mode='scaled')[source]

Flush changes to mmap and close mmap and fileref

pad_file_for_point_recs(num_recs)[source]

Pad the file with null bytes out to a calculated length based on the data given. This is usually a side effect of set_dimension being called for the first time on a file in write mode.

set_dimension(name, new_dim)[source]

Set a dimension (X,Y,Z etc) to the given value.

set_header_property(name, value)[source]

Wrapper for _set_datum, accepting name of header property and formatted value

set_padding(value)[source]

Set the padding between end of VLRs and beginning of point data

set_points(points)[source]

Set the point data for the file, using either a list of laspy.util.Point instances, or a numpy array of point data (as recieved from get_points).

class laspy.base.DataProvider(filename, manager)[source]

Provides access to the file object, the memory map, and the numpy point map.

__getitem__(index)[source]

Return the raw bytes corresponding to the point @ index.

__setitem__(key, value)[source]

Assign raw bytes for point @ key

close(flush=True)[source]

Close the data provider and flush changes if _mmap and _pmap exist.

get_point_map(informat)[source]

Get point map is used to build and return a numpy frombuffer view of the mmapped data, using a valid laspy.util.Format instance for the desired point format. This method is used to provide access to extra_bytes even when dimensions have been explicitly defined via an extra_bytes VLR record.

map()[source]

Memory map the file

open(mode)[source]

Open the file, catch simple problems.

point_map()[source]

Create the numpy point map based on the point format.

remap(flush=True, point_map=False)[source]

Re-map the file. Flush changes, close, open, and map. Optionally point map.