# API Documentation

## Re-exported functions

### laspy.read

laspy.read(source, closefd=True, laz_backend=(), decompression_selection: DecompressionSelection = <DecompressionSelection.XY_RETURNS_CHANNEL|Z|CLASSIFICATION|FLAGS|INTENSITY|SCAN_ANGLE|USER_DATA|POINT_SOURCE_ID|GPS_TIME|RGB|NIR|WAVEPACKET|ALL_EXTRA_BYTES: 8191>, encoding_errors: str = 'strict')

  Entry point for reading las data in laspy

  Reads the whole file into memory.

      >>> las = read_las("tests/data/simple.las")
      >>> las.classification
      <SubFieldView([1 1 1 ... 1 1 1])>

  Parameters:

    - source (str or io.BytesIO) – The source to read data from

    - laz_backend (Optional, the backend to use when the file is as LAZ file.) – By default laspy will find the backend to use by itself. Use if you want a specific backend to be used

    - closefd (bool) – if True and the source is a stream, the function will close it after it is done reading

    - decompression_selection (DecompressionSelection,) – see `laspy.open()`

    - encoding_errors (str, default 'strict') – Only used in writing and appending mode. How encoding errors should be treated. Possible values and their explanation can be seen here: https://docs.python.org/3/library/codecs.html#error-handlers.

  Returns:

    The object you can interact with to get access to the LAS points & VLRs

  Return type:

    laspy.LasData

  Added in version 2.4: The `decompression_selection` parameter.

  Added in version 2.6: The `encoding_errors` parameter.

### laspy.open

laspy.open(source, mode='r', closefd=True, laz_backend=None, header=None, do_compress=None, encoding_errors: str = 'strict', read_evlrs: bool = True, decompression_selection: DecompressionSelection = <DecompressionSelection.XY_RETURNS_CHANNEL|Z|CLASSIFICATION|FLAGS|INTENSITY|SCAN_ANGLE|USER_DATA|POINT_SOURCE_ID|GPS_TIME|RGB|NIR|WAVEPACKET|ALL_EXTRA_BYTES: 8191>) → LasReader | LasWriter | LasAppender

  The laspy.open opens a LAS/LAZ file in one of the 3 supported mode:

  > - “r” => Reading => a `laspy.LasReader` will be returned

  > - “w” => Writing => a `laspy.LasWriter` will be returned

  > - “a” => Appending => a `laspy.LasAppender` will be returned

  When opening a file in ‘w’ mode, a header (`laspy.LasHeader`) is required

      >>> with open_las('tests/data/simple.las') as f:
      ...     print(f.header.point_format.id)
      3

      >>> f = open('tests/data/simple.las', mode='rb')
      >>> with open_las(f,closefd=False) as flas:
      ...     print(flas.header)
      <LasHeader(1.2, <PointFormat(3, 0 bytes of extra dims)>)>
      >>> f.closed
      False
      >>> f.close()
      >>> f.closed
      True

      >>> f = open('tests/data/simple.las', mode='rb')
      >>> with open_las(f) as flas:
      ...    las = flas.read()
      >>> f.closed
      True

  Parameters:

    - source (str or bytes or io.BytesIO) – if source is a str it must be a filename

    - mode (Optional, the mode to open the file:) –

      - “r” for reading (default)

      - ”w” for writing

      - ”a” for appending

    - laz_backend (Optional, laspy.LazBackend, the LAZ backend to use to handle decompression/compression) – By default available backends are detected, see LazBackend to see the preference order when multiple backends are available

    - header (The header to use when opening in write mode.)

    - do_compress (optional, bool, only meaningful in writing mode:) –

      - None (default) guess if compression is needed using the file extension or if a laz_backend was explicitely provided

      - True compresses the file

      - False do not compress the file

    - closefd (optional, bool, True by default) – Whether the stream/file object shall be closed, this only work when using open_las in a with statement. An exception is raised if closefd is specified and the source is a filename

    - encoding_errors (str, default 'strict') – Only used in writing and appending mode. How encoding errors should be treated. Possible values and their explanation can be seen here: https://docs.python.org/3/library/codecs.html#error-handlers.

    - read_evlrs (bool, default True) –

      Only applies to ‘r’ mode.

      If True the evlrs will be read during the __init__ / file opening along with the LasHeader.

      It is fine for most of the cases, but can be problematic when opening file from a data stream like AWS S3 as EVLRs are located at the end of the files, thus will require to pull the whole file.

      Does nothing if the input file does not support EVLRs

    - decompression_selection (DecompressionSelection, default All) –

      Only applies to ‘r’ mode and for files which suport selective decompression (version >= 1.4 and point format id >= 6), ignored otherwise.

      Allows to select which fields should be decompressed or not, allowing to save time by not decompressing unused fields.

      By default all fields are decompressed

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

### laspy.create

laspy.create(*, point_format: int | PointFormat | None = None, file_version: str | Version | None = None)

  Function to create a new empty las data object

  Note

  If you provide both point_format and file_version an exception will be raised if they are not compatible

      >>> las = create_las(point_format=6,file_version="1.2")
      Traceback (most recent call last):
       ...
      laspy.errors.LaspyException: Point format 6 is not compatible with file version 1.2

  If you provide only the point_format the file_version will automatically selected for you.

      >>> las = create_las(point_format=0)
      >>> las.header.version == '1.2'
      True

      >>> las = create_las(point_format=PointFormat(6))
      >>> las.header.version == '1.4'
      True

  Parameters:

    - point_format – The point format you want the created file to have

    - file_version – The las version you want the created las to have

  Returns:

    A new las data object

  Return type:

    laspy.lasdatas.base.LasBase

### laspy.convert

laspy.convert(source_las, *, point_format_id=None, file_version=None)

  Converts a Las from one point format to another Automatically upgrades the file version if source file version is not compatible with the new point_format_id

  convert to point format 0

      >>> las = read_las('tests/data/simple.las')
      >>> las.header.version
      Version(major=1, minor=2)
      >>> las = convert(las, point_format_id=0)
      >>> las.header.point_format.id
      0
      >>> str(las.header.version)
      '1.2'

  convert to point format 6, which need version >= 1.4 then convert back to point format 0, version is not downgraded

      >>> las = read_las('tests/data/simple.las')
      >>> str(las.header.version)
      '1.2'
      >>> las = convert(las, point_format_id=6)
      >>> las.header.point_format.id
      6
      >>> str(las.header.version)
      '1.4'
      >>> las = convert(las, point_format_id=0)
      >>> str(las.header.version)
      '1.4'

  an exception is raised if the requested point format is not compatible with the file version

      >>> las = read_las('tests/data/simple.las')
      >>> convert(las, point_format_id=6, file_version='1.2')
      Traceback (most recent call last):
       ...
      laspy.errors.LaspyException: Point format 6 is not compatible with file version 1.2

  Parameters:

    - source_las (laspy.lasdatas.base.LasBase) – The source data to be converted

    - point_format_id (int, optional) – The new point format id (the default is None, which won’t change the source format id)

    - file_version (str, optional,) – The new file version. None by default which means that the file_version may be upgraded for compatibility with the new point_format. The file version will not be downgraded.

  Return type:

    laspy.lasdatas.base.LasBase

## Re-exported classes

> - `LasHeader`

> - `LasData`

> - `PointFormat`

> - `VLR`

> - `ExtraBytesParams`

> - `LasReader`

> - `LasWriter`

> - `LasAppender`

> - `PackedPointRecord`

> - `ScaleAwarePointRecord`

> - `CopcReader`

## Submodules

- laspy.lib module
  - `open_las()`
  - `read_las()`
  - `mmap_las()`
  - `create_las()`
  - `convert()`
  - `write_then_read_again()`
- laspy.header module
  - LasHeader
    - `LasHeader`
      - `LasHeader.DEFAULT_VERSION`
      - `LasHeader.DEFAULT_POINT_FORMAT`
      - `LasHeader.file_source_id`
      - `LasHeader.uuid`
      - `LasHeader.system_identifier`
      - `LasHeader.generating_software`
      - `LasHeader.creation_date`
      - `LasHeader.point_count`
      - `LasHeader.scales`
      - `LasHeader.offsets`
      - `LasHeader.number_of_points_by_return`
      - `LasHeader.extra_header_bytes`
      - `LasHeader.extra_vlr_bytes`
      - `LasHeader.start_of_waveform_data_packet_record`
      - `LasHeader.start_of_first_evlr`
      - `LasHeader.number_of_evlrs`
      - `LasHeader.max_gps_time`
      - `LasHeader.min_gps_time`
      - `LasHeader.gps_time_offset`
      - `LasHeader.evlrs`
      - `LasHeader.point_format`
      - `LasHeader.version`
      - `LasHeader.x_scale`
      - `LasHeader.y_scale`
      - `LasHeader.z_scale`
      - `LasHeader.x_offset`
      - `LasHeader.y_offset`
      - `LasHeader.z_offset`
      - `LasHeader.x_max`
      - `LasHeader.y_max`
      - `LasHeader.z_max`
      - `LasHeader.x_min`
      - `LasHeader.y_min`
      - `LasHeader.z_min`
      - `LasHeader.vlrs`
      - `LasHeader.add_extra_dims()`
      - `LasHeader.add_extra_dim()`
      - `LasHeader.add_crs()`
      - `LasHeader.remove_extra_dim()`
      - `LasHeader.remove_extra_dims()`
      - `LasHeader.set_version_and_point_format()`
      - `LasHeader.grow()`
      - `LasHeader.max_point_count()`
      - `LasHeader.copy()`
      - `LasHeader.parse_crs()`
      - `LasHeader.read_evlrs()`
      - `LasHeader.major_version`
      - `LasHeader.minor_version`
- laspy.lasreader module
  - LasReader
    - `LasReader`
      - `LasReader.__init__()`
      - `LasReader.evlrs`
      - `LasReader.point_source`
      - `LasReader.read_points()`
      - `LasReader.read()`
      - `LasReader.seek()`
      - `LasReader.chunk_iterator()`
      - `LasReader.read_evlrs()`
      - `LasReader.close()`
- laspy.lasdata module
  - LasData
    - `LasData`
      - `LasData.point_format`
      - `LasData.xyz`
      - `LasData.points`
      - `LasData.vlrs`
      - `LasData.evlrs`
      - `LasData.add_extra_dim()`
      - `LasData.add_extra_dims()`
      - `LasData.remove_extra_dims()`
      - `LasData.remove_extra_dim()`
      - `LasData.update_header()`
      - `LasData.write()`
      - `LasData.change_scaling()`
- laspy.copc module
  - CopcReader
    - `CopcReader`
      - `CopcReader.__init__()`
      - `CopcReader.open()`
      - `CopcReader.query()`
      - `CopcReader.spatial_query()`
      - `CopcReader.level_query()`
    - `Bounds`
      - `Bounds.__init__()`
      - `Bounds.mins`
      - `Bounds.maxs`
      - `Bounds.overlaps()`
      - `Bounds.ensure_3d()`
- laspy.vlrs.vlrlist module
  - `VLRList`
    - `VLRList.index()`
    - `VLRList.get_by_id()`
    - `VLRList.get()`
    - `VLRList.extract()`
    - `VLRList.read_from()`
    - `VLRList.write_to()`
- laspy.vlrs.known module
  - `IKnownVLR`
    - `IKnownVLR.official_user_id()`
    - `IKnownVLR.official_record_ids()`
    - `IKnownVLR.record_data_bytes()`
    - `IKnownVLR.parse_record_data()`
  - `BaseKnownVLR`
    - `BaseKnownVLR.from_raw()`
  - `ClassificationLookupVlr`
    - `ClassificationLookupVlr.parse_record_data()`
    - `ClassificationLookupVlr.record_data_bytes()`
    - `ClassificationLookupVlr.official_user_id()`
    - `ClassificationLookupVlr.official_record_ids()`
  - `LasZipVlr`
    - `LasZipVlr.parse_record_data()`
    - `LasZipVlr.record_data_bytes()`
    - `LasZipVlr.official_user_id()`
    - `LasZipVlr.official_record_ids()`
    - `LasZipVlr.from_raw()`
  - `ExtraBytesStruct`
    - `ExtraBytesStruct.NO_DATA_BIT_MASK`
    - `ExtraBytesStruct.MIN_BIT_MASK`
    - `ExtraBytesStruct.MAX_BIT_MASK`
    - `ExtraBytesStruct.SCALE_BIT_MASK`
    - `ExtraBytesStruct.OFFSET_BIT_MASK`
    - `ExtraBytesStruct.no_data`
    - `ExtraBytesStruct.min`
    - `ExtraBytesStruct.max`
    - `ExtraBytesStruct.offset`
    - `ExtraBytesStruct.scale`
    - `ExtraBytesStruct.format_name()`
    - `ExtraBytesStruct.dtype()`
    - `ExtraBytesStruct.num_elements()`
    - `ExtraBytesStruct.min_is_relevant()`
    - `ExtraBytesStruct.max_is_relevant()`
    - `ExtraBytesStruct.grow()`
    - `ExtraBytesStruct.partial_reset()`
    - `ExtraBytesStruct.size()`
    - `ExtraBytesStruct.data_type`
    - `ExtraBytesStruct.description`
    - `ExtraBytesStruct.name`
    - `ExtraBytesStruct.options`
    - `ExtraBytesStruct.reserved`
    - `ExtraBytesStruct.unused`
  - `ExtraBytesVlr`
    - `ExtraBytesVlr.extra_bytes_structs`
    - `ExtraBytesVlr.parse_record_data()`
    - `ExtraBytesVlr.record_data_bytes()`
    - `ExtraBytesVlr.type_of_extra_dims()`
    - `ExtraBytesVlr.grow()`
    - `ExtraBytesVlr.partial_reset()`
    - `ExtraBytesVlr.official_user_id()`
    - `ExtraBytesVlr.official_record_ids()`
  - `WaveformPacketStruct`
    - `WaveformPacketStruct.size()`
    - `WaveformPacketStruct.bits_per_sample`
    - `WaveformPacketStruct.digitizer_gain`
    - `WaveformPacketStruct.digitizer_offset`
    - `WaveformPacketStruct.number_of_samples`
    - `WaveformPacketStruct.temporal_sample_spacing`
    - `WaveformPacketStruct.waveform_compression_type`
  - `WaveformPacketVlr`
    - `WaveformPacketVlr.parse_record_data()`
    - `WaveformPacketVlr.record_data_bytes()`
    - `WaveformPacketVlr.official_record_ids()`
    - `WaveformPacketVlr.official_user_id()`
    - `WaveformPacketVlr.from_raw()`
  - `GeoKeyEntryStruct`
    - `GeoKeyEntryStruct.size()`
    - `GeoKeyEntryStruct.count`
    - `GeoKeyEntryStruct.id`
    - `GeoKeyEntryStruct.tiff_tag_location`
    - `GeoKeyEntryStruct.value_offset`
  - `GeoKeysHeaderStructs`
    - `GeoKeysHeaderStructs.size()`
    - `GeoKeysHeaderStructs.key_directory_version`
    - `GeoKeysHeaderStructs.key_revision`
    - `GeoKeysHeaderStructs.minor_revision`
    - `GeoKeysHeaderStructs.number_of_keys`
  - `GeoKeyDirectoryVlr`
    - `GeoKeyDirectoryVlr.parse_record_data()`
    - `GeoKeyDirectoryVlr.record_data_bytes()`
    - `GeoKeyDirectoryVlr.parse_crs()`
    - `GeoKeyDirectoryVlr.official_user_id()`
    - `GeoKeyDirectoryVlr.official_record_ids()`
  - `GeoDoubleParamsVlr`
    - `GeoDoubleParamsVlr.parse_record_data()`
    - `GeoDoubleParamsVlr.record_data_bytes()`
    - `GeoDoubleParamsVlr.official_user_id()`
    - `GeoDoubleParamsVlr.official_record_ids()`
  - `GeoAsciiParamsVlr`
    - `GeoAsciiParamsVlr.parse_record_data()`
    - `GeoAsciiParamsVlr.record_data_bytes()`
    - `GeoAsciiParamsVlr.official_user_id()`
    - `GeoAsciiParamsVlr.official_record_ids()`
  - `WktMathTransformVlr`
    - `WktMathTransformVlr.parse_record_data()`
    - `WktMathTransformVlr.record_data_bytes()`
    - `WktMathTransformVlr.official_user_id()`
    - `WktMathTransformVlr.official_record_ids()`
  - `WktCoordinateSystemVlr`
    - `WktCoordinateSystemVlr.parse_record_data()`
    - `WktCoordinateSystemVlr.record_data_bytes()`
    - `WktCoordinateSystemVlr.parse_crs()`
    - `WktCoordinateSystemVlr.official_user_id()`
    - `WktCoordinateSystemVlr.official_record_ids()`
  - `vlr_factory()`
- laspy.vlrs.vlr
  - `VLR`
    - `VLR.record_data`
    - `VLR.record_data_bytes()`
    - `VLR.description`
    - `VLR.record_id`
    - `VLR.user_id`
- laspy.point.record module
  - `scale_dimension()`
  - `unscale_dimension()`
  - `DimensionNameValidity`
    - `DimensionNameValidity.Valid`
    - `DimensionNameValidity.Unsupported`
    - `DimensionNameValidity.Invalid`
  - `PackedPointRecord`
    - `PackedPointRecord.point_size`
    - `PackedPointRecord.zeros()`
    - `PackedPointRecord.empty()`
    - `PackedPointRecord.from_point_record()`
    - `PackedPointRecord.from_buffer()`
    - `PackedPointRecord.copy_fields_from()`
    - `PackedPointRecord.copy()`
    - `PackedPointRecord.memoryview()`
    - `PackedPointRecord.resize()`
    - `PackedPointRecord.validate_dimension_name()`
  - `apply_new_scaling()`
  - `ScaleAwarePointRecord`
    - `ScaleAwarePointRecord.zeros()`
    - `ScaleAwarePointRecord.empty()`
    - `ScaleAwarePointRecord.change_scaling()`
- laspy.errors module
  - `LaspyException`
  - `UnknownExtraType`
  - `PointFormatNotSupported`
  - `FileVersionNotSupported`
  - `LazError`
  - `IncompatibleDataFormat`
- laspy.compression module
  - LazBackend
    - `LazBackend`
      - `LazBackend.LazrsParallel`
      - `LazBackend.Lazrs`
      - `LazBackend.Laszip`
      - `LazBackend.is_available()`
      - `LazBackend.supports_append`
      - `LazBackend.create_appender()`
      - `LazBackend.create_reader()`
      - `LazBackend.create_writer()`
      - `LazBackend.detect_available()`
  - DecompressionSelection
    - `DecompressionSelection`
      - `DecompressionSelection.XY_RETURNS_CHANNEL`
      - `DecompressionSelection.Z`
      - `DecompressionSelection.CLASSIFICATION`
      - `DecompressionSelection.FLAGS`
      - `DecompressionSelection.INTENSITY`
      - `DecompressionSelection.SCAN_ANGLE`
      - `DecompressionSelection.USER_DATA`
      - `DecompressionSelection.POINT_SOURCE_ID`
      - `DecompressionSelection.GPS_TIME`
      - `DecompressionSelection.RGB`
      - `DecompressionSelection.NIR`
      - `DecompressionSelection.WAVEPACKET`
      - `DecompressionSelection.ALL_EXTRA_BYTES`
      - `DecompressionSelection.all()`
      - `DecompressionSelection.base()`
      - `DecompressionSelection.xy_returns_channel()`
      - `DecompressionSelection.to_lazrs()`
      - `DecompressionSelection.to_laszip()`
      - `DecompressionSelection.is_set()`
      - `DecompressionSelection.decompress_all_extra_bytes()`
      - `DecompressionSelection.skip_all_extra_bytes()`
      - `DecompressionSelection.is_set_all_extra_bytes()`
      - `DecompressionSelection.decompress_classification()`
      - `DecompressionSelection.skip_classification()`
      - `DecompressionSelection.is_set_classification()`
      - `DecompressionSelection.decompress_flags()`
      - `DecompressionSelection.skip_flags()`
      - `DecompressionSelection.is_set_flags()`
      - `DecompressionSelection.decompress_gps_time()`
      - `DecompressionSelection.skip_gps_time()`
      - `DecompressionSelection.is_set_gps_time()`
      - `DecompressionSelection.decompress_intensity()`
      - `DecompressionSelection.skip_intensity()`
      - `DecompressionSelection.is_set_intensity()`
      - `DecompressionSelection.decompress_nir()`
      - `DecompressionSelection.skip_nir()`
      - `DecompressionSelection.is_set_nir()`
      - `DecompressionSelection.decompress_point_source_id()`
      - `DecompressionSelection.skip_point_source_id()`
      - `DecompressionSelection.is_set_point_source_id()`
      - `DecompressionSelection.decompress_rgb()`
      - `DecompressionSelection.skip_rgb()`
      - `DecompressionSelection.is_set_rgb()`
      - `DecompressionSelection.decompress_scan_angle()`
      - `DecompressionSelection.skip_scan_angle()`
      - `DecompressionSelection.is_set_scan_angle()`
      - `DecompressionSelection.decompress_user_data()`
      - `DecompressionSelection.skip_user_data()`
      - `DecompressionSelection.is_set_user_data()`
      - `DecompressionSelection.decompress_wavepacket()`
      - `DecompressionSelection.skip_wavepacket()`
      - `DecompressionSelection.is_set_wavepacket()`
      - `DecompressionSelection.decompress_xy_returns_channel()`
      - `DecompressionSelection.skip_xy_returns_channel()`
      - `DecompressionSelection.is_set_xy_returns_channel()`
      - `DecompressionSelection.decompress_z()`
      - `DecompressionSelection.skip_z()`
      - `DecompressionSelection.is_set_z()`
- laspy.point.format module
  - `ExtraBytesParams`
    - `ExtraBytesParams.name`
    - `ExtraBytesParams.type`
    - `ExtraBytesParams.description`
    - `ExtraBytesParams.offsets`
    - `ExtraBytesParams.scales`
    - `ExtraBytesParams.no_data`
  - `PointFormat`
    - `PointFormat.id`
    - `PointFormat.dimensions`
    - `PointFormat.standard_dimensions`
    - `PointFormat.extra_dimensions`
    - `PointFormat.dimension_names`
    - `PointFormat.standard_dimension_names`
    - `PointFormat.extra_dimension_names`
    - `PointFormat.size`
    - `PointFormat.num_standard_bytes`
    - `PointFormat.num_extra_bytes`
    - `PointFormat.has_waveform_packet`
    - `PointFormat.dimension_by_name()`
    - `PointFormat.add_extra_dimension()`
    - `PointFormat.remove_extra_dimension()`
    - `PointFormat.dtype()`
  - `lost_dimensions()`
- laspy.lasmmap module
  - `LasMMAP`
    - `LasMMAP.close()`
- laspy.lasappender
  - LasAppender
    - `LasAppender`
      - `LasAppender.append_points()`
- laspy.laswriter module
  - LasWriter
    - `LasWriter`
      - `LasWriter.__init__()`
      - `LasWriter.write_points()`
      - `LasWriter.write_evlrs()`
      - `LasWriter.close()`