pylas.vlrs.vlrlist module

class pylas.vlrs.vlrlist.RawVLRList(iterable=None)[source]

Bases: object

A RawVLRList is like a VLR list but it should only hold RawVLRs.

This class is meant to make it easier to write VLRS the the file and know in advance the size in bytes taken by all the VLRs combined

append(raw_vlr)[source]
classmethod from_list(vlrs)[source]

Construct a RawVLR list from a list of vlrs

Parameters:vlrs (iterable of VLR) –
Returns:
Return type:RawVLRList
total_size_in_bytes()[source]
write_to(out_stream)[source]

Writes all the raw vlrs contained in list to the out_stream

Parameters:out_stream (io.RawIOBase) – The stream where vlrs will be written to
class pylas.vlrs.vlrlist.VLRList[source]

Bases: object

Class responsible for managing the vlrs

append(vlr)[source]

append a vlr to the list

Parameters:vlr (RawVlR or VLR or KnownVlr) –
extend(vlr_list)[source]

append all elements of the vlr_list into self

extract(vlr_type)[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 from_list(vlr_list)[source]
get(vlr_type)[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 pylas
>>> las = pylas.read("pylastests/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
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 pylas
>>> from pylas.vlrs.known import ExtraBytesVlr, WktCoordinateSystemVlr
>>> las = pylas.read("pylastests/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

index(vlr_type)[source]
pop(index)[source]
classmethod read_from(data_stream, num_to_read)[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
Returns:

List of vlrs

Return type:

pylas.vlrs.vlrlist.VLRList