laspy.lasreader module

LasReader

class laspy.lasreader.LasReader(source: ~typing.BinaryIO, closefd: bool = True, laz_backend: ~typing.Optional[~typing.Union[~laspy._compression.backend.LazBackend, ~typing.Iterable[~laspy._compression.backend.LazBackend]]] = None, read_evlrs: bool = True, decompression_selection: ~laspy._compression.selection.DecompressionSelection = DecompressionSelection.None)[source]

Bases: object

The reader class handles LAS and LAZ via one of the supported backend

__init__(source: ~typing.BinaryIO, closefd: bool = True, laz_backend: ~typing.Optional[~typing.Union[~laspy._compression.backend.LazBackend, ~typing.Iterable[~laspy._compression.backend.LazBackend]]] = None, read_evlrs: bool = True, decompression_selection: ~laspy._compression.selection.DecompressionSelection = DecompressionSelection.None)[source]

Initialize the LasReader

Parameters:
  • source (file_object) –

  • closefd (bool, default True) –

  • laz_backend (LazBackend or list of LazBackend, optional) –

  • read_evlrs (bool, default True) – only applies to __init__ phase, and for files that support evlrs

  • decompression_selection (optional, DecompressionSelection) – Selection of fields to decompress, only works form point format >= 6 <= 10 Ignored on other point formats

  • versionadded: (..) – 2.4: The read_evlrs and decompression_selection parameters.

property evlrs: Optional[VLRList]
property point_source: IPointReader
read_points(n: int) ScaleAwarePointRecord[source]

Read n points from the file

Will only read as many points as the header advertise. That is, if you ask to read 50 points and there are only 45 points left this function will only read 45 points.

If there are no points left to read, returns an empty point record.

Parameters:

n (The number of points to read) – if n is less than 0, this function will read the remaining points

read() LasData[source]

Reads all the points that are not read and returns a LasData object

This will also read EVLRS

seek(pos: int, whence: int = 0) int[source]

Seeks to the start of the point at the given pos

Parameters:
  • pos (index of the point to seek to) –

  • whence (optional, controls how the pos parameter is interpreted:) – io.SEEK_SET: (default) pos is the index of the point from the beginning io.SEEK_CUR: pos is the point_index relative to the point_index of the last point read io.SEEK_END: pos is the point_index relative to last point

Return type:

The index of the point the reader seeked to, relative to the first point

chunk_iterator(points_per_iteration: int) PointChunkIterator[source]

Returns an iterator, that will read points by chunks of the requested size

Parameters:

points_per_iteration – number of points to be read with each iteration

Returns:

read_evlrs()[source]
close() None[source]

closes the file object used by the reader