# laspy.copc module

## CopcReader

class laspy.copc.CopcReader(stream, close_fd: bool = True, http_num_threads: int = 20, _http_strategy: str = 'queue', 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)

  Bases: `object`

  Class allowing to do queries over a COPC LAZ

  In short, COPC files are LAZ 1.4 files organized in a particular way (Octree) making it possible to do spatial queries as well as queries with a level of details.

  CopcReader requires the `lazrz` backend to work.

  Optionaly, if `requests` is installed, CopcReader can handle Copc files that are on a remote HTTP server

  This class only reads COPC files, it does not support normal LAS/LAZ files.

  To create an instance of it you’ll likely want to use the `CopcReader.open()` constructor

  New in version 2.2.

  __init__(stream, close_fd: bool = True, http_num_threads: int = 20, _http_strategy: str = 'queue', 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)

    Creates a CopcReader.

    Parameters:

      - stream (the stream from where data can be read.) – It must have the following file object methods: read, seek, tell

      - http_num_threads (int, optional, default num cpu * 5) – Number of worker threads to do concurent HTTP requests, ignored when reading non-HTTP file

      - close_fd (optional, default bool) – Whether the stream/file object shall be closed, this only work when using the CopcReader in a with statement.

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

    New in version 2.4: The `decompression_selection` parameter.

  classmethod open(source: str | PathLike | IOBase, http_num_threads: int = 20, _http_strategy: str = 'queue', 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) → CopcReader

    Opens the COPC file.

    Parameters:

      - source (str, io.IOBase, uri or file-like object of the COPC file.) –

        Supported sources are:

        > - ’local’ files accesible with a path.

        > - HTTP / HTTPS endpoints. The pyhon package `requests` is required in order to be able to work with HTTP endpoints.

        > - file-like objects, e.g. fsspec io.IOBase objects.

      - http_num_threads (int, optional, default num cpu * 5) – Number of worker threads to do concurent HTTP requests, ignored when reading non-HTTP file

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

    Opening a local file

        from laspy import CopcReader

        with CopcReader.open("some_file.laz") as reader:
            ...

    Opening a file on a remite HTTP server (`requests` package required)

        from laspy import CopcReader

        url = "https://s3.amazonaws.com/hobu-lidar/autzen-classified.copc.laz"
        with CopcReader.open(url) as reader:
            ...

    New in version 2.4: The `decompression_selection` parameter.

  query(bounds: Bounds | None = None, resolution: float | int | None = None, level: int | range | None = None) → ScaleAwarePointRecord

    ” Query the COPC file to retrieve the points matching the requested bounds and level.

    Parameters:

      - bounds (Bounds, optional, default None) – The bounds for which you wish to aquire points. If None, the whole file’s bounds will be considered 2D bounds are suported, (No point will be filtered on its Z coordinate)

      - resolution (float or int, optional, default None) –

        Limits the octree levels to be queried in order to have a point cloud with the requested resolution.

        - The unit is the one of the data.

        - If None, the resulting cloud will be at the full resolution offered by the COPC source

        - Mutually exclusive with level parameter

      - level (int or range, optional, default None) –

        The level of detail (LOD).

        - If None, all LOD are going to be considered

        - If it is an int, only points that are of the requested LOD will be returned.

        - If it is a range, points for which the LOD is within the range will be returned

  spatial_query(bounds: Bounds) → ScaleAwarePointRecord
  level_query(level: int | range) → ScaleAwarePointRecord

class laspy.copc.Bounds(mins: numpy.ndarray, maxs: numpy.ndarray)

  Bases: `object`

  __init__(mins: ndarray, maxs: ndarray) → None
  mins: ndarray
  maxs: ndarray
  overlaps(other: Bounds) → bool
  ensure_3d(mins: ndarray, maxs: ndarray) → Bounds