laspy.lasreader module

LasReader

class laspy.lasreader.LasReader(source: BinaryIO, closefd: bool = True, laz_backend: Optional[Union[LazBackend, Iterable[LazBackend]]] = None)[source]

Bases: object

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

__init__(source: BinaryIO, closefd: bool = True, laz_backend: Optional[Union[LazBackend, Iterable[LazBackend]]] = None)[source]

Initialize the LasReader

Parameters
  • source (file_object) –

  • closefd (bool, default True) –

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

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

Note

If the source file object is not seekable and the FILE contains 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

close() None[source]

closes the file object used by the reader