laspy.vlrs.vlrlist module

class laspy.vlrs.vlrlist.VLRList(*args, **kwargs)[source]

Bases: list

Class responsible for managing the vlrs

index(value, start: int = 0, stop: Optional[int] = None) int[source]

Return first index of value.

Raises ValueError if the value is not present.

get_by_id(user_id='', record_ids=(None,))[source]

Function to get vlrs by user_id and/or record_ids. Always returns a list even if only one vlr matches the user_id and record_id

>>> import laspy
>>> from laspy.vlrs.known import ExtraBytesVlr, WktCoordinateSystemVlr
>>> las = laspy.read("tests/data/extrabytes.las")
>>> las.vlrs
[<ExtraBytesVlr(extra bytes structs: 5)>]
>>> las.vlrs.get(WktCoordinateSystemVlr.official_user_id())
[]
>>> las.vlrs.get(WktCoordinateSystemVlr.official_user_id())[0]
Traceback (most recent call last):
IndexError: list index out of range
>>> las.vlrs.get_by_id(ExtraBytesVlr.official_user_id())
[<ExtraBytesVlr(extra bytes structs: 5)>]
>>> las.vlrs.get_by_id(ExtraBytesVlr.official_user_id())[0]
<ExtraBytesVlr(extra bytes structs: 5)>
Parameters
  • user_id (str, optional) – the user id

  • record_ids (iterable of int, optional) – THe record ids of the vlr(s) you wish to get

Returns

a list of vlrs matching the user_id and records_ids

Return type

list

get(vlr_type: str) List[IKnownVLR][source]

Returns the list of vlrs of the requested type Always returns a list even if there is only one VLR of type vlr_type.

>>> import laspy
>>> las = laspy.read("tests/data/extrabytes.las")
>>> las.vlrs
[<ExtraBytesVlr(extra bytes structs: 5)>]
>>> las.vlrs.get("WktCoordinateSystemVlr")
[]
>>> las.vlrs.get("WktCoordinateSystemVlr")[0]
Traceback (most recent call last):
IndexError: list index out of range
>>> las.vlrs.get('ExtraBytesVlr')
[<ExtraBytesVlr(extra bytes structs: 5)>]
>>> las.vlrs.get('ExtraBytesVlr')[0]
<ExtraBytesVlr(extra bytes structs: 5)>
Parameters

vlr_type (str) – the class name of the vlr

Returns

a List of vlrs matching the user_id and records_ids

Return type

list

extract(vlr_type: str) List[IKnownVLR][source]

Returns the list of vlrs of the requested type The difference with get is that the returned vlrs will be removed from the list

Parameters

vlr_type (str) – the class name of the vlr

Returns

a List of vlrs matching the user_id and records_ids

Return type

list

classmethod read_from(data_stream: BinaryIO, num_to_read: int, extended: bool = False) VLRList[source]

Reads vlrs and parse them if possible from the stream

Parameters
  • data_stream (io.BytesIO) – stream to read from

  • num_to_read (int) – number of vlrs to be read

  • extended (bool) – whether the vlrs are regular vlr or extended vlr

Returns

List of vlrs

Return type

laspy.vlrs.vlrlist.VLRList

write_to(stream: BinaryIO, as_extended: bool = False, encoding_errors: str = 'strict') int[source]