### Create and Write a Tileset Source: https://gitlab.com/py3dtiles/py3dtiles/-/blob/main/docs/api.md This example demonstrates the process of creating a tileset from LAS data, including defining root and child tiles, setting their content and bounding volumes, and writing the tileset to a directory. Ensure necessary libraries like laspy and numpy are installed. ```python >>> from pathlib import Path >>> >>> import laspy >>> import numpy as np >>> >>> from py3dtiles.tileset import Tile, TileSet >>> from py3dtiles.tileset.content import Pnts >>> from py3dtiles.tileset.content.pnts_feature_table import PntsFeatureTableHeader, SemanticPoint >>> >>> with laspy.open("tests/fixtures/with_srs_3950.las") as f: ... las_data = f.read() >>> points = las_data.points >>> >>> # Get few points for the root tile >>> indexes = np.random.choice(len(points), 100) >>> point_part = points[indexes] >>> positions = np.vstack((point_part.x, point_part.y, point_part.z)).T >>> feature_table_header = PntsFeatureTableHeader.from_semantic( ... SemanticPoint.POSITION, None, None, nb_points = 100 ... ) >>> root_tile = Tile(refine_mode="REPLACE", content_uri=Path("root.pnts")) >>> root_tile.tile_content = Pnts.from_features(feature_table_header, positions.flatten()) >>> root_tile.bounding_volume = BoundingVolumeBox.from_points(positions) >>> >>> # Split the points in 4 parts >>> split_len = len(points) // 4 >>> splits = [ ... (0, split_len), ... (split_len, split_len*2), ... (split_len*2, split_len*3), ... (split_len*3, None), ... ] >>> for start, end in splits: ... point_part = points[start : end] ... positions = np.vstack((point_part.x, point_part.y, point_part.z)).T ... feature_table_header = PntsFeatureTableHeader.from_semantic( ... SemanticPoint.POSITION, None, None, nb_points = len(point_part) ... ) ... tile = Tile(content_uri=Path(f"{start}.pnts")) ... tile.tile_content = Pnts.from_features(feature_table_header, positions.flatten()) ... tile.bounding_volume = BoundingVolumeBox.from_points(positions) ... root_tile.add_child(tile) >>> >>> # Create the tileset >>> tileset = TileSet() >>> tileset.root_tile = root_tile >>> tileset_path = Path("my3dtiles2/tileset.json") >>> tileset_path.parent.mkdir() >>> tileset.write_to_directory(tileset_path) ``` -------------------------------- ### Install Documentation Dependencies Source: https://gitlab.com/py3dtiles/py3dtiles/-/blob/main/docs/README.md Install the project and its documentation dependencies in a Python virtual environment. ```default pip install -e . pip install -e .[doc] ``` -------------------------------- ### Install py3dtiles from Source Source: https://gitlab.com/py3dtiles/py3dtiles/-/blob/main/docs/install.md Clone the repository, set up a virtual environment, and install py3dtiles using pip. ```shell apt install git python3 python3-pip virtualenv git clone git@gitlab.com:py3dtiles/py3dtiles.git cd py3dtiles virtualenv -p python3 venv . venv/bin/activate pip install . ``` -------------------------------- ### Install Pre-commit Hooks Source: https://gitlab.com/py3dtiles/py3dtiles/-/blob/main/CONTRIBUTING.md Install the pre-commit hooks using the provided configuration file. This sets up hooks for pre-commit, pre-push, and commit-msg stages. ```bash pre-commit install -c .pre-commit-config.yaml -f --install-hooks -t pre-push -t pre-commit -t commit-msg ``` -------------------------------- ### Install laspy with LAZ Support Source: https://gitlab.com/py3dtiles/py3dtiles/-/blob/main/docs/install.md Install the laspy library with LAZ support, which requires the liblaszip library to be installed system-wide. ```shell apt-get install -y liblaszip8 pip install laspy[laszip] ``` -------------------------------- ### Start Nix Dev Shell Source: https://gitlab.com/py3dtiles/py3dtiles/-/blob/main/nix/README.md Use this command to enter a development shell with Python 3.11 and set up a virtual environment. ```bash nix-shell pip-shell.nix ``` -------------------------------- ### Install py3dtiles with Development Dependencies Source: https://gitlab.com/py3dtiles/py3dtiles/-/blob/main/docs/install.md Install py3dtiles with development dependencies and set up for running unit tests using pytest. ```shell (venv)$ pip install -e .[dev] (venv)$ pytest ``` -------------------------------- ### TilerWorker.initialize Source: https://gitlab.com/py3dtiles/py3dtiles/-/blob/main/docs/api/py3dtiles.tilers.base_tiler.tiler_worker.md Method called once at the start of the process in the subprocess. ```APIDOC ## initialize() -> None ### Description This method will be called once at the start of the process in the subprocess, not in the main thread. Useful to initialize non-pickable objects on windows, for instance. ### Returns - None ``` -------------------------------- ### Install py3dtiles from PyPI Source: https://gitlab.com/py3dtiles/py3dtiles/-/blob/main/docs/install.md Use pip to install the py3dtiles package directly from the Python Package Index. ```shell pip install py3dtiles ``` -------------------------------- ### Install py3dtiles with Specific Format Support Source: https://gitlab.com/py3dtiles/py3dtiles/-/blob/main/docs/install.md Install py3dtiles with optional dependencies for specific file format support like LAS, PLY, or PostgreSQL. ```shell pip install py3dtiles[las] ``` ```shell pip install py3dtiles[ply] ``` ```shell pip install py3dtiles[postgres] ``` ```shell pip install py3dtiles[ifc] ``` ```shell pip install py3dtiles[obj] ``` ```shell pip install py3dtiles[postgres,ply,las,ifc,obj] ``` -------------------------------- ### Install Development Dependencies Source: https://gitlab.com/py3dtiles/py3dtiles/-/blob/main/CONTRIBUTING.md Install the necessary development dependencies for py3dtiles, including tools for linting and formatting. ```bash pip install .[dev] ``` -------------------------------- ### Read and Process Tileset with Python API Source: https://gitlab.com/py3dtiles/py3dtiles/-/blob/main/README.rst Load a tileset from a file, iterate through all tiles, fetch their content, and print information about the content type and bounding volume. This example demonstrates lazy loading and content retrieval. ```python from pathlib import Path from py3dtiles.tileset.tileset import TileSet tileset = TileSet.from_file(Path("tests/fixtures/tiles/tileset.json")) all_tiles = (tileset.root_tile, *tileset.root_tile.get_all_children()) for tile in all_tiles: if not tile.has_content(): continue tile_content = tile.get_or_fetch_content(tileset.root_uri) print(f"The tile {tile.content_uri} has a content of {type(tile_content)} type") print(f"with this bounding volume: {tile.bounding_volume.to_dict()}") ``` -------------------------------- ### Install Py3dtiles with Pip Source: https://gitlab.com/py3dtiles/py3dtiles/-/blob/main/README.rst Use pip to install the Py3dtiles library. For specific format dependencies, refer to the full documentation. ```bash pip install py3dtiles ``` -------------------------------- ### Convert Pointcloud to 3D Tiles using CLI Source: https://gitlab.com/py3dtiles/py3dtiles/-/blob/main/site/index.html Use the py3dtiles command-line tool to convert a pointcloud file (e.g., .las) into a 3D Tiles dataset. This is a quick way to get started with 3D Tiles conversion. ```bash py3dtiles convert --out="3dtiles" pointcloud.las ``` -------------------------------- ### Customize 3D Tiles Conversion with Custom Tilers Source: https://gitlab.com/py3dtiles/py3dtiles/-/blob/main/docs/api.md Customize the conversion process by creating and using custom tiler instances. This example shows how to inherit from PointTiler and add custom initialization logic. ```python >>> from pathlib import Path >>> >>> from py3dtiles.convert import Converter >>> from py3dtiles.tilers.point.point_tiler import PointTiler >>> >>> las_path = Path("tests/fixtures/with_srs_3857.las") >>> >>> # For demo purpose, we'll inherit PointTiler >>> class MyPointTiler(PointTiler): ... def initialize(self, *args, **kwargs) -> None: ... print("Custom initialization") ... super().initialize(*args, **kwargs) >>> >>> my_point_tiler = MyPointTiler(verbose=-1) >>> converter = Converter([my_point_tiler]) >>> # let's check if the tiler is indeed used >>> converter.convert(las_path, Path("3dtiles_output/"), overwrite=True) Custom initialization ``` -------------------------------- ### Tiler.print_summary Source: https://gitlab.com/py3dtiles/py3dtiles/-/blob/main/docs/api/py3dtiles.tilers.base_tiler.md Prints the summary of the tiler before the start of the conversion. ```APIDOC ## Tiler.print_summary ### Description Prints a summary of the tiler's configuration and status before the conversion process begins. ### Method `print_summary` ### Parameters None ### Returns `None` ``` -------------------------------- ### TilerWorker.initialize Source: https://gitlab.com/py3dtiles/py3dtiles/-/blob/main/docs/api/py3dtiles.tilers.base_tiler.md This method will be called once at the start of the process in the subprocess, not in the main thread. Useful to initialize non-pickable objects on windows, for instance. ```APIDOC ## TilerWorker.initialize ### Description Initializes the TilerWorker once at the start of the process in the subprocess. This is useful for initializing non-pickable objects, especially on Windows. ### Method `abstractmethod` ### Parameters None ### Returns `None` ``` -------------------------------- ### Serve Generated Documentation Locally Source: https://gitlab.com/py3dtiles/py3dtiles/-/blob/main/docs/README.md Use the Makefile for a convenient way to serve the generated documentation pages locally using Python's http.server module. ```sh make serve ``` -------------------------------- ### TileSet Class - Initialization Source: https://gitlab.com/py3dtiles/py3dtiles/-/blob/main/docs/api.md Demonstrates how to create a new TileSet object from scratch. ```APIDOC ## TileSet Class - Initialization ### Description Creates a new, empty TileSet object. The root tile is automatically initialized. ### Method `TileSet()` ### Example ```python from py3dtiles.tileset import TileSet tileset = TileSet() print(tileset.root_tile) ``` ``` -------------------------------- ### Generate Full API Documentation (Makefile) Source: https://gitlab.com/py3dtiles/py3dtiles/-/blob/main/docs/README.md Use the Makefile to automatically generate the API documentation. This command typically invokes sphinx-multiversion. ```default make apidoc ``` -------------------------------- ### Generate the Complete Website (Makefile) Source: https://gitlab.com/py3dtiles/py3dtiles/-/blob/main/docs/README.md Use the Makefile to generate the entire website, including both API documentation and static pages. ```sh make site ``` -------------------------------- ### Create a Tileset from Scratch Source: https://gitlab.com/py3dtiles/py3dtiles/-/blob/main/docs/api.md Instantiate a new TileSet object to begin creating a 3D Tileset. The root tile is automatically initialized. ```python from py3dtiles.tileset import TileSet tileset = TileSet() # when creating a tileset from scratch, the first tile (named root_tile) is initialized tileset.root_tile ``` -------------------------------- ### mkdir_or_raise Source: https://gitlab.com/py3dtiles/py3dtiles/-/blob/main/docs/api/py3dtiles.utils.md Creates a directory, with options to overwrite existing content or raise an error. ```APIDOC ## mkdir_or_raise ### Description Creates a directory if it does not exist or is empty. If the specified path is a file, or if it's a non-empty directory and `overwrite` is `False`, a `FileExistsError` is raised. If `overwrite` is `True`, any existing non-empty directory at the path will be removed before creating the new directory. ### Parameters - **folder** (Path) - The path object representing the directory to create. - **overwrite** (bool) - If `True`, existing non-empty directories will be removed. Defaults to `False`. ### Raises - **FileExistsError** - If `folder` is a file or a non-empty directory and `overwrite` is `False`. ``` -------------------------------- ### PointTiler.initialize Source: https://gitlab.com/py3dtiles/py3dtiles/-/blob/main/docs/api/py3dtiles.tilers.point.point_tiler.md Initializes the conversion process by gathering metadata from input files. ```APIDOC ## def initialize(self, files: list[Path], working_dir: Path, out_folder: Path) -> None ### Description This method will be called first by convert to initialize the conversion process. Tilers will receive all the paths information as argument to this method. Only files supported by this tiler will be in the files argument. Tilers are expected to gather metadata from those input files so that subsequent call to get_tasks can generate some conversion work to do by workers. This method is probably a good place to init the SharedMetadata subclass instance as well. ### Parameters * **files** (list[Path]) - List of input file paths supported by this tiler. * **working_dir** (Path) - A temporary directory where this tiler can store intermediate results. * **out_folder** (Path) - The output folder for this tiler. ``` -------------------------------- ### Load Geometry from WKB and Create B3DM Source: https://gitlab.com/py3dtiles/py3dtiles/-/blob/main/docs/api.md Load geometry from an ISO WKB file, define its bounding box and transformation, and create a B3DM tile. The geometry is processed using TriangleSoup and saved as a .b3dm file. ```python >>> from pathlib import Path >>> >>> import numpy as np >>> >>> from py3dtiles.tilers.b3dm.wkb_utils import TriangleSoup >>> from py3dtiles.tileset.content import B3dm >>> >>> # load a wkb file (ISO WKB format only) >>> wkb = open('tests/fixtures/building/building.wkb', 'rb').read() >>> >>> # define the geometry's bounding box >>> box = [[-8.75, -7.36, -2.05], [8.80, 7.30, 2.05]] >>> >>> # define the geometry's world transformation >>> transform = np.array([ ... [1, 0, 0, 1842015.125], ... [0, 1, 0, 5177109.25], ... [0, 0, 1, 247.87364196777344], ... [0, 0, 0, 1]], dtype=float) >>> >>> # use the TriangleSoup helper class to transform the wkb into arrays >>> # of points and triangles >>> ts = TriangleSoup.from_wkb_multipolygon(wkb) >>> positions = ts.get_position_array() >>> normals = ts.get_normal_array() >>> # Create a b3dm directly from the arrays of geometries. >>> # It stores the data in GlTF format in the tile body. >>> tile_content = B3dm.from_numpy_arrays( ... ts.vertices, ... ts.triangle_indices, ... normal=ts.compute_normals(), ... transform=transform, ... ) >>> # to save our tile content as a .b3dm file >>> tile_content.save_as(Path("mymodel.b3dm")) ``` -------------------------------- ### Tiler.initialize Source: https://gitlab.com/py3dtiles/py3dtiles/-/blob/main/docs/api/py3dtiles.tilers.base_tiler.md This method will be called first by convert to initialize the conversion process. Tilers will receive all the paths information as argument to this method. Only files supported by this tiler will be in the files argument. ```APIDOC ## Tiler.initialize ### Description Initializes the tiler with file paths, a working directory, and an output folder. Tilers should gather metadata from input files to prepare for task generation. ### Method `abstractmethod` ### Parameters * **files** (list[Path]) - A list of paths to input files supported by this tiler. * **working_dir** (Path) - A temporary directory for intermediate results. * **out_folder** (Path) - The output folder for the tiler. ### Returns `None` ``` -------------------------------- ### Utility Function Source: https://gitlab.com/py3dtiles/py3dtiles/-/blob/main/docs/api/py3dtiles.tileset.content.md Provides a utility function for getting color semantics. ```APIDOC ## `get_color_semantic()` Retrieves the color semantic information. ``` -------------------------------- ### build_secure_conn Source: https://gitlab.com/py3dtiles/py3dtiles/-/blob/main/docs/api/py3dtiles.export.md Get a psycopg2 connection securely, e.g. without writing the password explicitly in the terminal. ```APIDOC ## build_secure_conn(db_conn_info: str) -> psycopg2.extensions.connection ### Description Get a psycopg2 connection securely, e.g. without writing the password explicitely in the terminal ### Parameters #### Path Parameters - **db_conn_info** (str) - Description of the database connection information. ### Returns - **psycopg2.extensions.connection** - A secure psycopg2 connection object. ``` -------------------------------- ### Display py3dtiles Docker Image Help Source: https://gitlab.com/py3dtiles/py3dtiles/-/blob/main/docker/README.md Run the Docker image interactively to display its help message. This is useful for understanding available commands and options. ```bash docker run -it --rm py3dtiles --help ``` -------------------------------- ### Create Bounding Volume Box from List Source: https://gitlab.com/py3dtiles/py3dtiles/-/blob/main/docs/api.md Initializes a BoundingVolumeBox using a list of center and half-axis values. The `to_dict()` method shows the initial representation. ```python >>> import numpy as np >>> >>> from py3dtiles.tileset import BoundingVolumeBox >>> >>> center = [0, 0, 0] >>> x_half_axis = [3, 3, 3] >>> y_half_axis = [3, 3, 3] >>> z_half_axis = [1, 0, 0] >>> >>> bounding_box = BoundingVolumeBox.from_list([*center, *x_half_axis, *y_half_axis, *z_half_axis]) >>> bounding_box.to_dict() {'box': [np.float64(0.0), np.float64(0.0), np.float64(0.0), np.float64(3.0), np.float64(3.0), np.float64(3.0), np.float64(3.0), np.float64(3.0), np.float64(3.0), np.float64(1.0), np.float64(0.0), np.float64(0.0)]} ``` -------------------------------- ### Points Class Source: https://gitlab.com/py3dtiles/py3dtiles/-/blob/main/docs/api/py3dtiles.points.md Represents an arbitrary amount of points. Each property contains one element per vertex. For example, 'positions' is an array of coordinate triplets. ```APIDOC class py3dtiles.points.Points(positions: ndarray[tuple[int, ...], dtype[float32 | uint16]], colors: ndarray[tuple[int, ...], dtype[uint8 | uint16 | float32]] | None = None, extra_fields: dict[str, ndarray[tuple[int, ...], dtype[Any]]] | None = None) Bases: object This class represents an arbitrary amount of points. Each properties contains one elem per *vertices*. Ex: positions is an array of coordinates triplet. Ex: [[1, 2, 3], [3, 4, 5]] extra_fields should be a dict. The property name is the field name, the values is a flat array of values Attributes: colors (ndarray[tuple[int, ...], dtype[uint8 | uint16 | float32]] | None): Color information for the points. extra_fields (dict[str, ndarray[tuple[int, ...], dtype[Any]]] | None): Additional fields associated with the points. positions (ndarray[tuple[int, ...], dtype[float32 | uint16]]): Positional coordinates of the points. Methods: transform(transform: ndarray[tuple[int, ...], dtype[float64]]) -> None: Applies a transformation matrix to the points. ``` -------------------------------- ### Update Python Dependencies for Docker Source: https://gitlab.com/py3dtiles/py3dtiles/-/blob/main/docker/README.md Update Python dependencies within the Docker environment. This involves creating a virtual environment, installing dependencies, and updating the requirements file. ```bash python -m venv .venvdocker source .venvdocker/bin/activate pip install .[postgres,ply,las,ifc,obj] && pip install laspy[laszip] pip freeze | grep -v py3dtiles > docker/requirements.txt ``` -------------------------------- ### Get Info about a PNTS Tile Source: https://gitlab.com/py3dtiles/py3dtiles/-/blob/main/docs/cli.md Prints detailed information about a point cloud tile in PNTS format, including header details, feature table, and data for the first point. ```shell $ py3dtiles info tests/pointCloudRGB.pnts Tile Header ----------- Magic Value: pnts Version: 1 Tile byte length: 15176 Feature table json byte length: 148 Feature table bin byte length: 15000 Feature Table Header -------------------- {'POSITION': {'byteOffset': 0}, 'RGB': {'byteOffset': 12000}, 'POINTS_LENGTH': 1000, 'RTC_CENTER': [1215012.8828876738, -4736313.051199594, 4081605.22126042]} First point ----------- {'Z': -0.17107764, 'Red': 44, 'X': 2.19396, 'Y': 4.4896851, 'Green': 243, 'Blue': 209} ``` -------------------------------- ### View a 3D Tileset Source: https://gitlab.com/py3dtiles/py3dtiles/-/blob/main/docs/cli.md Opens a local web server and a browser to visualize a specified 3D Tileset JSON file. ```shell $ py3dtiles view 3dtiles/tileset.json ``` -------------------------------- ### BoundingVolume Source: https://gitlab.com/py3dtiles/py3dtiles/-/blob/main/docs/api/py3dtiles.tileset.md Abstract base class for bounding volumes. It defines the interface for operations like adding other bounding volumes, constructing from dictionaries, getting center and half-size, checking validity, serialization, transformation, and translation. ```APIDOC ## class py3dtiles.tileset.BoundingVolume ### Description Abstract class used as interface for box, region and sphere. ### Methods #### abstractmethod add(other: BoundingVolume) -> None Compute the ‘canonical’ bounding volume fitting this bounding volume together with the added bounding volume. * **Parameters:** **other** – another bounding volume to be added with this one #### abstractmethod classmethod from_dict(bounding_volume_dict: _BoundingVolumeJsonDictT) -> Self Construct a bounding volume from a dict. The implementor should support each possible format in the 3dtiles spec relevant to the specific flavor of bounding volume. #### abstractmethod get_center() -> ndarray[tuple[int, ...], dtype[float64]] Returns the center of this bounding volume. #### abstractmethod get_half_size() -> ndarray[tuple[int, ...], dtype[float64]] Returns the half size of this volume as a 3 elements array #### abstractmethod is_valid() -> bool Test if the bounding volume is correctly defined. #### abstractmethod to_dict() -> _BoundingVolumeJsonDictT Serialize this bounding volume into its JSON representation, ready to be embedded in a tileset. #### abstractmethod transform(transform: ndarray[tuple[int, ...], dtype[float64]]) -> None Apply the provided transformation matrix (4x4) to the volume * **Parameters:** **transform** – transformation matrix (4x4) to be applied #### abstractmethod translate(offset: ndarray[tuple[int, ...], dtype[float64]]) -> None Translate the volume center with the given offset “vector” * **Parameters:** **offset** – the 3D vector by which the volume should be translated ``` -------------------------------- ### Load and Parse a Tileset using py3dtiles API Source: https://gitlab.com/py3dtiles/py3dtiles/-/blob/main/site/index.html Integrate py3dtiles into your Python application to read and manipulate 3D Tiles datasets. This example shows how to load a tileset from a JSON file using the API. ```python import json from pathlib import Path from py3dtiles.tileset import TileSet tileset_path = Path("tests/fixtures/tiles/tileset.json") with tileset_path.open() as f: tileset = TileSet.from_dict(json.load(f)) ``` -------------------------------- ### initialize Source: https://gitlab.com/py3dtiles/py3dtiles/-/blob/main/docs/api/py3dtiles.tilers.base_tiler.tiler.md Initializes the conversion process by gathering metadata from input files. This method is called first by the convert function. ```APIDOC ## initialize(files: list[Path], working_dir: Path, out_folder: Path) -> None ### Description This method will be called first by convert to initialize the conversion process. Tilers will receive all the paths information as argument to this method. Only files supported by this tiler will be in the files argument. Tilers are expected to gather metadata from those input files so that subsequent call to get_tasks can generate some conversion work to do by workers. This method is probably a good place to init the SharedMetadata subclass instance as well. ### Parameters * **files** (list[Path]) - The list of input files supported by this tiler. * **working_dir** (Path) - A temporary directory where this tiler can store intermediate results. * **out_folder** (Path) - The output folder for this tiler. ``` -------------------------------- ### NodeProcess Class Source: https://gitlab.com/py3dtiles/py3dtiles/-/blob/main/docs/api/py3dtiles.tilers.point.node.node_process.md Initializes a NodeProcess object with catalog, scale, name, tasks, begin timestamp, and an optional log file. ```APIDOC class py3dtiles.tilers.point.node.node_process.NodeProcess(node_catalog: [NodeCatalog](py3dtiles.tilers.point.node.node_catalog.md#py3dtiles.tilers.point.node.node_catalog.NodeCatalog), scale: float, name: bytes, tasks: list[bytes], begin: float, log_file: TextIO | None) ``` -------------------------------- ### get_attribute Source: https://gitlab.com/py3dtiles/py3dtiles/-/blob/main/docs/api/py3dtiles.tileset.content.gltf_utils.md Retrieves all values for a specified attribute name from a glTF 2.0 file, respecting indices. The returned array contains values in a structured manner. For example, `get_attribute(gltf, ‘POSITION’)` returns an array of 3-element arrays. This method guarantees consistent traversal order of meshes and primitives but does not guarantee the attribute's presence. It only supports glTF files with a BINARYBLOB buffer format. ```APIDOC ## get_attribute(gltf: GLTF2, attribute_name: str) -> ndarray[tuple[int, ...], dtype[Any]] | None ### Description Get all the values having this attribute_name in this gltf, respecting the indices if there are some. The returning array contains all the value in a structured manner: get_attribute(gltf, ‘POSITION’) will give back an array of 3-elements arrays. Note: this method guarantees to walk the meshes and primitives always in the same order, but there is no guarantee that each mesh has this particular attribute. Warning: this method only supports gltf with a buffer format of BINARYBLOB (see pygltflib BufferFormat enum) ``` -------------------------------- ### from_directory Source: https://gitlab.com/py3dtiles/py3dtiles/-/blob/main/docs/api/py3dtiles.export.md Exports 3D tiles from a directory. ```APIDOC ## from_directory(directory, offset, output_dir) -> None ### Description Exports 3D tiles from a directory. ### Parameters #### Path Parameters - **directory** (Path) - The directory containing the input data. - **offset** (tuple) - The offset to apply to the coordinates. - **output_dir** (Path) - The directory to save the tileset. ``` -------------------------------- ### Write .glb File from Meshes Source: https://gitlab.com/py3dtiles/py3dtiles/-/blob/main/docs/api.md Shows how to create a .glb file using py3dtiles helper classes for GltfMesh and GltfPrimitive. This is a higher-level approach compared to direct pygltflib manipulation. ```python >>> from py3dtiles.tileset.content.gltf_utils import GltfMesh, GltfPrimitive, gltf_from_meshes >>> from pygltflib import Material, PbrMetallicRoughness >>> import numpy as np >>> >>> m1 = Material(pbrMetallicRoughness=PbrMetallicRoughness(baseColorFactor=[1, 0, 0])) >>> m2 = Material(pbrMetallicRoughness=PbrMetallicRoughness(baseColorFactor=[0, 1, 0])) >>> >>> p1 = GltfPrimitive(indices=np.array([0, 1, 3], dtype=np.uint8), material=m1) >>> p2 = GltfPrimitive(indices=np.array([1, 2, 3], dtype=np.uint8), material=m2) >>> mesh = GltfMesh(points=np.array([[0, 0, 0], [1, 0, 0], [1, 1, 1], [0, 0, 1]], dtype=np.float32), primitives=[p1, p2]) >>> >>> gltf = gltf_from_meshes([mesh]) >>> gltf.save("test.glb") True ``` -------------------------------- ### Build API Documentation for a Specific Version Source: https://gitlab.com/py3dtiles/py3dtiles/-/blob/main/docs/README.md Generate the API documentation for a specific version of the project, typically the latest commit (HEAD). This command is executed from the Sphinx documentation directory. ```default sphinx-build -A current_version=HEAD -A "versions=[main]" -b html . ../_build/html ``` -------------------------------- ### Build the py3dtiles Docker Image Source: https://gitlab.com/py3dtiles/py3dtiles/-/blob/main/docker/README.md Build the Docker image from the repository root. This command creates two tags for Docker Hub and GitLab Container Registry. ```bash docker build . -t py3dtiles/py3dtiles:v8.0.0 -t registry.gitlab.com/py3dtiles/py3dtiles:v8.0.0 -f docker/Dockerfile ``` -------------------------------- ### Tiler.supports Source: https://gitlab.com/py3dtiles/py3dtiles/-/blob/main/docs/api/py3dtiles.tilers.base_tiler.md This function tells the main process if this tiler supports this file or not. The main process will use the first supporting tiler it finds for each file. ```APIDOC ## Tiler.supports ### Description Determines if the tiler can process a given file. This method should be efficient and not require reading the entire file. ### Method `abstractmethod` ### Parameters * **file** (Path) - The path to the file to check. ### Returns `bool` - True if the tiler supports the file, False otherwise. ### Request Example ```python if my_tiler.supports(Path('data.las')): print('This tiler supports LAS files.') ``` ``` -------------------------------- ### wkbs_to_tileset Source: https://gitlab.com/py3dtiles/py3dtiles/-/blob/main/docs/api/py3dtiles.export.md Converts Well-Known Binary (WKB) data into a 3D Tileset. ```APIDOC ## wkbs_to_tileset(wkbs: list[bytes], ids: list[str] | None, transform: ndarray[tuple[int, ...], dtype[float32]], output_dir: Path) -> None ### Description Converts Well-Known Binary (WKB) data into a 3D Tileset. ### Parameters #### Path Parameters - **wkbs** (list[bytes]) - A list of Well-Known Binary (WKB) data. - **ids** (list[str] | None) - A list of IDs for the tiles. Defaults to None. - **transform** (ndarray[tuple[int, ...], dtype[float32]]) - The transformation matrix to apply. - **output_dir** (Path) - The directory to save the tileset. ``` -------------------------------- ### run Source: https://gitlab.com/py3dtiles/py3dtiles/-/blob/main/docs/api/py3dtiles.reader.las_reader.md Reads points from a LAS file with specified options. ```APIDOC ## run(filename: str, offset_scale: tuple[ndarray[tuple[int, ...], dtype[float64]], ndarray[tuple[int, ...], dtype[float64]], ndarray[tuple[int, ...], dtype[float64]] | None, float | None], portion: tuple[int, ...], transformer: Transformer | None, color_scale: float | None, with_rgb: bool, extra_fields: list[ExtraFieldsDescription]) -> Iterator[tuple[ndarray[tuple[int, ...], dtype[float32]], ndarray[tuple[int, ...], dtype[uint8]] | None, dict[str, ndarray[tuple[int, ...], dtype[Any]]]]] ### Description Reads points from a LAS file. ### Parameters * **filename** (str) - The path to the LAS file. * **offset_scale** (tuple[ndarray[tuple[int, ...], dtype[float64]], ndarray[tuple[int, ...], dtype[float64]], ndarray[tuple[int, ...], dtype[float64]] | None, float | None]) - Offset and scale information. * **portion** (tuple[int, ...]) - Specifies a portion of the file to read. * **transformer** (Transformer | None, optional) - A transformation to apply to the points. Defaults to None. * **color_scale** (float | None, optional) - A scale factor for color values. Defaults to None. * **with_rgb** (bool) - Whether to include RGB color information. * **extra_fields** (list[ExtraFieldsDescription]) - A list of descriptions for extra fields to read. ### Returns * Iterator[tuple[ndarray[tuple[int, ...], dtype[float32]], ndarray[tuple[int, ...], dtype[uint8]] | None, dict[str, ndarray[tuple[int, ...], dtype[Any]]]]] - An iterator yielding tuples of points, optional RGB data, and extra fields. ``` -------------------------------- ### Grid Class Initialization Source: https://gitlab.com/py3dtiles/py3dtiles/-/blob/main/docs/api/py3dtiles.tilers.point.node.points_grid.md Initializes a Grid object with specified spacing, RGB inclusion, and extra fields. ```APIDOC ## class py3dtiles.tilers.point.node.points_grid.Grid ### Description Initializes a Grid object. ### Parameters - **spacing** (float) - The spacing between grid cells. - **include_rgb** (bool) - Whether to include RGB color data. - **extra_fields** (list[ExtraFieldsDescription]) - A list of descriptions for extra fields. - **initial_count** (int) - Optional initial count for cells. Defaults to 3. ``` -------------------------------- ### BoundingVolumeBox.from_mins_maxs Source: https://gitlab.com/py3dtiles/py3dtiles/-/blob/main/docs/api/py3dtiles.tileset.md Builds a BoundingVolumeBox instance from minimum and maximum coordinate values. ```APIDOC ## BoundingVolumeBox.from_mins_maxs ### Description Builds a BoundingVolumeBox instance from minimum and maximum coordinate values. Internally calls set_from_mins_maxs. ### Method classmethod ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **mins_maxs** (ndarray[tuple[int, ...], dtype[float64]] | list[float]) - Required - the array [x_min, y_min, z_min, x_max, y_max, z_max] that is the boundaries of the box along each coordinate axis ### Returns - **BoundingVolumeBox** - a new instance of BoundingVolumeBox ``` -------------------------------- ### TileSet.from_file Source: https://gitlab.com/py3dtiles/py3dtiles/-/blob/main/docs/api/py3dtiles.tileset.tileset.md Creates a TileSet object from a tileset file. ```APIDOC ## from_file ### Description Creates a TileSet object from a tileset file. ### Method `TileSet.from_file(tileset_path: Path)` ### Parameters #### Path Parameters - **tileset_path** (Path) - Required - The path to the tileset file. ``` -------------------------------- ### Writing a .pnts file Source: https://gitlab.com/py3dtiles/py3dtiles/-/blob/main/docs/api.md Illustrates how to create and write a .pnts file from numpy arrays containing point data. ```APIDOC ## Writing a .pnts file ### Description This code snippet demonstrates how to construct a .pnts file programmatically using numpy arrays for point data and saving it to disk. ### Method `Pnts.from_features(feature_table_header, positions)` and `pnts.save_as(filepath)` ### Parameters #### `Pnts.from_features` Parameters - **feature_table_header** (PntsFeatureTableHeader) - Required - Defines the structure of the feature table. - **positions** (numpy.ndarray) - Required - A flattened numpy array containing point positions. #### `pnts.save_as` Parameters - **filepath** (Path) - Required - The path where the .pnts file will be saved. ### Request Example ```python import numpy as np from pathlib import Path from py3dtiles.tileset.content import Pnts from py3dtiles.tileset.content.pnts_feature_table import PntsFeatureTableHeader, SemanticPoint # Create position data positions = np.array([ (4.489, 2.19, -0.17), (8.65, 12.2, -0.17), ], dtype=np.float32).flatten() # Create feature table header feature_table_header = PntsFeatureTableHeader.from_semantic(SemanticPoint.POSITION, None, None, nb_points = 2) # Create Pnts object pnts = Pnts.from_features(feature_table_header, positions) # Save the file pnts.save_as(Path("mypoints.pnts")) ``` ### Response #### Success Response (File saved) - The .pnts file is created at the specified path. #### Example Usage ```python # Verify the header of the created Pnts object print(pnts.body.feature_table.header.to_json()) ``` ``` -------------------------------- ### Run Pre-commit Hooks Source: https://gitlab.com/py3dtiles/py3dtiles/-/blob/main/HOW_TO_MAINTAIN.md After making changes related to Python version support, run `pre-commit run --all-files` to apply automatic code formatting and upgrades. ```bash pre-commit run --all-files ``` -------------------------------- ### supports Source: https://gitlab.com/py3dtiles/py3dtiles/-/blob/main/docs/api/py3dtiles.tilers.base_tiler.tiler.md Determines if the tiler can process a given file. This check should be efficient and not require reading the entire file. ```APIDOC ## supports(file: Path) -> bool ### Description This function tells the main process if this tiler supports this file or not. The main process will use the first supporting tiler it finds for each file. Implementation should not require to read the whole file to determine if this tiler supports it. In other words, the execution time should be a constant regardless of the file size. ### Parameters * **file** (Path) - The path to the file to check. ### Returns * bool - True if the tiler supports the file, False otherwise. ``` -------------------------------- ### Export Directory to 3D Tiles with Offset Source: https://gitlab.com/py3dtiles/py3dtiles/-/blob/main/docs/cli.md Performs a directory export of geometries from .wkb files into 3D Tiles format. Coordinates are read as floats, so an offset can be applied to correctly place the tileset. ```shell $ py3dtiles export -d my_directory -o 10000 10000 0 ``` -------------------------------- ### Generate Static Site Pages (Makefile) Source: https://gitlab.com/py3dtiles/py3dtiles/-/blob/main/docs/README.md Use the Makefile to generate only the static site pages, excluding those generated by Sphinx. ```sh make static-site ``` -------------------------------- ### TileContent.from_file Source: https://gitlab.com/py3dtiles/py3dtiles/-/blob/main/docs/api/py3dtiles.tileset.content.tile_content.md Loads a tile content from a file path. ```APIDOC ## TileContent.from_file ### Description Load a tile content from a file path. ### Method `classmethod` ### Parameters - **tile_path** (Path) - The path to the tile file. ### Returns - `Self` - An instance of TileContent loaded from the file. ``` -------------------------------- ### B3dmBody Class Methods Source: https://gitlab.com/py3dtiles/py3dtiles/-/blob/main/docs/api/py3dtiles.tileset.content.md Methods for creating and accessing the body of a B3DM tile. ```APIDOC ## B3dmBody Class ### Description Represents the body of a B3DM tile, containing feature table and glTF data. ### Methods - **`B3dmBody.feature_table`**: Access the feature table within the B3DM body. - **`B3dmBody.from_array(array)`**: Create a B3DMBody object from a byte array. - **`B3dmBody.from_gltf(gltf_data)`**: Create a B3DMBody object from glTF data. - **`B3dmBody.from_meshes(meshes)`**: Create a B3DMBody object from a list of meshes. - **`B3dmBody.to_array()`**: Convert the B3DMBody object to a byte array. ``` -------------------------------- ### PointTiler Class Initialization Source: https://gitlab.com/py3dtiles/py3dtiles/-/blob/main/docs/api/py3dtiles.tilers.point.point_tiler.md Initializes the PointTiler with various configuration options for processing point cloud data. ```APIDOC ## class py3dtiles.tilers.point.point_tiler.PointTiler ### Description Tiler that split pointclouds. This tiler is able to reproject pointclouds, and can embed arbitrary fields in the resulting 3dtiles. ### Parameters * **crs_in** (CRS | None) - crs to use for files that don’t have crs information in their metadata, or for all files if force_crs_in is used * **crs_out** (CRS | None) - output crs * **force_crs_in** (bool) - whether or not to apply crs_in for all files. * **pyproj_always_xy** (bool) - some crs defines an axis order, but some dataset still use xy order nonetheless. This boolean allows to support this case. * **cache_size** (int) - the size in MB to use for ram cache. * **verbose** (int) - verbosity level * **number_of_jobs** (int) - how many process this tiler is allowed to use * **spec_version** (SpecVersion) - the 3D Tiles spec version to use. * **rgb** (bool) - whether to include rgb info or not * **color_scale** (float | None) - scale the color in the case of colors wrongly encoded in 8 bit in a 16-bit field (like in las/laz files). * **extra_fields** (list[str] | None) - the list of extra fields to include in the resulting 3dtiles ``` -------------------------------- ### print_summary Source: https://gitlab.com/py3dtiles/py3dtiles/-/blob/main/docs/api/py3dtiles.tilers.base_tiler.tiler.md Prints a summary of the tiler's status before the conversion process begins. ```APIDOC ## print_summary() -> None ### Description Prints the summary of the tiler before the start of the conversion. ``` -------------------------------- ### LegacyTileContent Methods Source: https://gitlab.com/py3dtiles/py3dtiles/-/blob/main/docs/api/py3dtiles.tileset.content.md Provides methods for interacting with legacy 3D Tiles content, including loading, saving, and accessing header and body information. ```APIDOC ## LegacyTileContent ### Description Represents legacy 3D Tiles content, offering methods to load, save, and access its components. ### Methods #### `LegacyTileContent.body` Access the body of the legacy tile content. #### `LegacyTileContent.from_array(array)` Creates a `LegacyTileContent` instance from a numpy array. #### `LegacyTileContent.from_bytes(bytes)` Creates a `LegacyTileContent` instance from raw bytes. #### `LegacyTileContent.get_batch_table_binary_property(name)` Retrieves a binary property from the batch table by its name. #### `LegacyTileContent.get_extra_field_names()` Gets the names of any extra fields present in the content. #### `LegacyTileContent.header` Access the header of the legacy tile content. #### `LegacyTileContent.save_as(path)` Saves the legacy tile content to a specified path. #### `LegacyTileContent.sync()` Synchronizes the content, ensuring all data is up-to-date. #### `LegacyTileContent.to_array()` Converts the legacy tile content to a numpy array. ``` -------------------------------- ### Create and Load Tile Content Source: https://gitlab.com/py3dtiles/py3dtiles/-/blob/main/docs/api.md Demonstrates loading binary tile content (PNTS) into a Tile object and setting its content URI. Note that content data and URI are separate variables in py3dtiles. ```python >>> from pathlib import Path >>> >>> from py3dtiles.tileset import Tile >>> from py3dtiles.tileset.content import read_binary_tile_content >>> >>> tile = Tile() >>> # the pnts is loaded and linked to the tile >>> tile.tile_content = read_binary_tile_content(Path("tests/fixtures/pointCloudRGB.pnts")) >>> # the uri that will be written in the tileset.json (and the path where the pnts will be writen) >>> tile.content_uri = Path("tiles/1.pnts") ``` -------------------------------- ### BoundingVolumeBox.from_points Source: https://gitlab.com/py3dtiles/py3dtiles/-/blob/main/docs/api/py3dtiles.tileset.md Constructs a BoundingVolumeBox that encloses a given set of points. ```APIDOC ## BoundingVolumeBox.from_points ### Description Constructs a BoundingVolumeBox that encloses a given set of points. Internally calls set_from_points. ### Method classmethod ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **points** (Sequence[ndarray[tuple[int, ...], dtype[float64]]] | list[float]] | ndarray[tuple[int, ...], dtype[Any]]) - Required - A sequence of 3D points. ### Returns - **BoundingVolumeBox** - a new instance of BoundingVolumeBox ``` -------------------------------- ### from_db Source: https://gitlab.com/py3dtiles/py3dtiles/-/blob/main/docs/api/py3dtiles.export.md Exports 3D tiles from a database. ```APIDOC ## from_db(db_conn_info, table_name, column_name, id_column_name, output_dir) -> None ### Description Exports 3D tiles from a database. ### Parameters #### Path Parameters - **db_conn_info** (str) - Database connection information. - **table_name** (str) - The name of the table to export from. - **column_name** (str) - The name of the column containing the geometry data. - **id_column_name** (str) - The name of the column containing the IDs. - **output_dir** (Path) - The directory to save the tileset. ``` -------------------------------- ### create_tileset_from_root_tiles Source: https://gitlab.com/py3dtiles/py3dtiles/-/blob/main/docs/api/py3dtiles.merger.md Creates a TileSet from a list of root tiles. This function calculates a world transformation and applies it to each tile before adding them to the TileSet. It's important that the content of each root tile is loaded before calling this method. ```APIDOC ## create_tileset_from_root_tiles ### Description Creates a TileSet from all the root tiles. This method will calculate a reasonable world-transformation and reverse-apply it to each tile transformation before adding them to the tileset. NOTE: each element of root_tiles *must* have its content loaded if their content uri is defined before calling this method. The resulting TileSet might have a root tile with contents. It’s the responsibility of the caller to save this content on disk (see [`py3dtiles.tileset.tile.Tile.write_content`](py3dtiles.tileset.tile.md#py3dtiles.tileset.tile.Tile.write_content)). ### Parameters #### Path Parameters - **root_tiles** (list[[Tile]]) - Required - A list of Tile objects representing the root tiles. - **spec_version** ([SpecVersion]) - Optional - The version of the 3D Tiles specification to use. Defaults to SpecVersion.V1_0. ### Returns - **TileSet** - A TileSet object containing the merged tiles. ``` -------------------------------- ### Grid.init_cells Source: https://gitlab.com/py3dtiles/py3dtiles/-/blob/main/docs/api/py3dtiles.tilers.point.node.points_grid.md Initializes the grid cells with provided bounding box information and point data. ```APIDOC ## init_cells ### Description Initializes the grid cells. ### Parameters - **aabmin** (ndarray[tuple[int, ...], dtype[float32]]) - The minimum corner of the AABB. - **inv_aabb_size** (ndarray[tuple[int, ...], dtype[float32]]) - The inverse of the AABB size. - **xyz** (ndarray[tuple[int, ...], dtype[float32 | uint16]]) - The XYZ coordinates of the points. - **rgb** (ndarray[tuple[int, ...], dtype[uint8 | uint16]] | None) - Optional RGB color data for the points. - **extra_fields** (dict[str, ndarray[tuple[int, ...], dtype[Any]]]) - A dictionary of extra fields for the points. ``` -------------------------------- ### BoundingVolume Methods Source: https://gitlab.com/py3dtiles/py3dtiles/-/blob/main/docs/api/py3dtiles.tileset.bounding_volume.md This section details the abstract methods available in the BoundingVolume class, which must be implemented by concrete bounding volume types. ```APIDOC ## BoundingVolume Class ### Description Abstract class used as interface for box, region and sphere. ### Methods #### add(other: BoundingVolume) -> None Compute the ‘canonical’ bounding volume fitting this bounding volume together with the added bounding volume. The computed fitting bounding volume is generically not the smallest one (due to its alignment with the coordinate axis). * **Parameters:** **other** – another bounding volume to be added with this one #### from_dict(bounding_volume_dict: _BoundingVolumeJsonDictT) -> Self Construct a bounding volume from a dict. The implementor should support each possible format in the 3dtiles spec relevant to the specific flavor of bounding volume. #### get_center() -> ndarray[tuple[int, ...], dtype[float64]] Returns the center of this bounding volume. #### get_half_size() -> ndarray[tuple[int, ...], dtype[float64]] Returns the half size of this volume as a 3 elements array #### is_valid() -> bool Test if the bounding volume is correctly defined. #### to_dict() -> _BoundingVolumeJsonDictT Serialize this bounding volume into its JSON representation, ready to be embedded in a tileset. #### transform(transform: ndarray[tuple[int, ...], dtype[float64]]) -> None Apply the provided transformation matrix (4x4) to the volume * **Parameters:** **transform** – transformation matrix (4x4) to be applied #### translate(offset: ndarray[tuple[int, ...], dtype[float64]]) -> None Translate the volume center with the given offset “vector” * **Parameters:** **offset** – the 3D vector by which the volume should be translated ```