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]

Close the file.


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


Return the header object, or create one if absent.


Wrapper for grabbing unpacked header data with _get_datum


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


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


calculate the number of point records


Return the raw bytestring associated with point of number index


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


Catalogue the variable length records

class laspy.base.Writer(filename, mode, header=False, vlrs=False, evlrs=False)[source]
close(ignore_header_changes=False, minmax_mode='scaled')[source]

Flush changes to mmap and close mmap and fileref


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_datum(rec_offs, dim, val)[source]

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

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 the padding between end of VLRs and beginning of point data


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.


Return the raw bytes corresponding to the point @ index.

__setitem__(key, value)[source]

Assign raw bytes for point @ key


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


Memory map the file


Open the file, catch simple problems.


Create the numpy point map based on the point format.


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.

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

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

Previous topic


Next topic