laspy.copc module


class laspy.copc.CopcReader(stream, close_fd: bool = True, http_num_threads: int = 10, _http_strategy: str = 'queue')[source]

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 constructor

__init__(stream, close_fd: bool = True, http_num_threads: int = 10, _http_strategy: str = 'queue')[source]

Creates a CopcReader.

  • 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.

classmethod open(uri: str, http_num_threads: int = 10, _http_strategy: str = 'queue') CopcReader[source]

Opens the COPC file.

  • uri (str, uri of the COPC file.) –

    Supported uri 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.

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

Opening a local file

from laspy import CopcReader

with"some_file.laz") as reader:

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

from laspy import CopcReader

url = ""
with as reader:
query(bounds: Optional[Bounds] = None, resolution: Optional[Union[float, int]] = None, level: Optional[Union[int, range]] = None) ScaleAwarePointRecord[source]

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

  • 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[source]
level_query(level: Union[int, range]) ScaleAwarePointRecord[source]
class laspy.copc.Bounds(mins: numpy.ndarray, maxs: numpy.ndarray)[source]

Bases: object

__init__(mins: ndarray, maxs: ndarray) None
mins: ndarray
maxs: ndarray
overlaps(other: Bounds) bool[source]
ensure_3d(mins: ndarray, maxs: ndarray) Bounds[source]