py3dtiles package

class py3dtiles.B3dm[source]

Bases: TileContent

static from_array(array)[source]

Parameters

array : numpy.array

Returns

t : TileContent

static from_glTF(gltf, bt=None)[source]

Parameters

gltfGlTF

glTF object representing a set of objects

btBatch Table (optional)

BatchTable object containing per-feature metadata

Returns

tile : TileContent

class py3dtiles.BatchTable[source]

Bases: object

Only the JSON header has been implemented for now. According to the batch table documentation, the binary body is useful for storing long arrays of data (better performances)

add_property_from_array(property_name, array)[source]
to_array()[source]
class py3dtiles.BoundingVolumeBox[source]

Bases: BoundingVolume

A box bounding volume as defined in the 3DTiles specifications i.e. an array of 12 numbers that define an oriented bounding box: - The first three elements define the x, y, and z values for the

center of the box.

  • The next three elements (with indices 3, 4, and 5) define the x axis direction and half-length.

  • The next three elements (with indices 6, 7, and 8) define the y axis direction and half-length.

  • The last three elements (indices 9, 10, and 11) define the z axis direction and half-length.”

Note that, by default, a box bounding volume doesn’t need to be aligned with the coordinate axis. Still in general, computing the box bounding volume of two box bounding volumes won’t necessarily yield a box that is aligned with the coordinate axis (although this computation might require some fitting algorithm e.g. the principal component analysis method. Yet in sake of simplification (and numerical efficiency), when asked to “add” (i.e. to find the enclosing box of) two (or more) box bounding volumes this class resolves to compute the “canonical” fitting/enclosing box i.e. a box that is parallel to the coordinate axis.

add(other: BoundingVolumeBox) None[source]

Compute the ‘canonical’ bounding volume fitting this bounding volume together with the added bounding volume. Again (refer above to the class definition) the computed fitting bounding volume is generically not the smallest one (due to its alignment with the coordinate axis). :param other: another box bounding volume to be added with this one

static get_box_array_from_mins_maxs(mins_maxs: list | ndarray) ndarray[source]
Parameters:

mins_maxs – the list [x_min, y_min, z_min, x_max, y_max, z_max] that is the boundaries of the box along each coordinate axis

Returns:

the smallest box (as an array, as opposed to a BoundingVolumeBox instance) that encloses the given list of (3D) points and that is parallel to the coordinate axis.

static get_box_array_from_point(points: list[list[float]]) ndarray[source]
Parameters:

points – a list of 3D points

Returns:

the smallest box (as an array, as opposed to a BoundingVolumeBox instance) that encloses the given list of (3D) points and that is parallel to the coordinate axis.

get_canonical_as_array() ndarray[source]
Returns:

the smallest enclosing box (as an array) that is parallel to the coordinate axis

get_center() ndarray[source]
get_corners() list[source]
Returns:

the corners (3D points) of the box as a list

is_box() bool[source]
static is_valid(box) tuple[bool, str][source]
set_from_array(box_array: ndarray) None[source]
set_from_list(box_list: list) None[source]
set_from_mins_maxs(mins_maxs: list | ndarray) None[source]
Parameters:

mins_maxs – the list [x_min, y_min, z_min, x_max, y_max, z_max] that is the boundaries of the box along each coordinate axis

set_from_points(points: list) None[source]
sync_with_children(owner: Tile) None[source]
to_dict() dict[source]
transform(transform: list[float] | ndarray) None[source]

Apply the provided transformation matrix (4x4) to the box :param transform: transformation matrix (4x4) to be applied

translate(offset: list | ndarray) None[source]

Translate the box center with the given offset “vector” :param offset: the 3D vector by which the box should be translated

class py3dtiles.Extendable[source]

Bases: object

One the 3DTiles notions defined as an abstract data model through a schema of the 3DTiles specifications (either core of extensions).

add_extension(extension: Extension) None[source]
get_extension(extension_name: str) Extension[source]
get_extensions() list[Extension][source]
has_extensions() bool[source]
class py3dtiles.Extension(name: str)[source]

Bases: object

An instance of some ExtensionType.

to_dict() dict[source]
class py3dtiles.Feature[source]

Bases: object

static from_array(positions_dtype, positions, colors_dtype=None, colors=None)[source]

Parameters

positions_dtype : numpy.dtype

positionsnumpy.array

Array of uint8.

colors_dtype : numpy.dtype

colorsnumpy.array

Array of uint8.

Returns

f : Feature

static from_values(x, y, z, red=None, green=None, blue=None)[source]
to_array()[source]
class py3dtiles.GlTF[source]

Bases: object

CHUNK_HEADER_LENGTH = 8
HEADER_LENGTH = 12
static from_array(array)[source]

Parameters

array : numpy.array

Returns

glTF : GlTf

static from_binary_arrays(arrays, transform, batched=True, uri=None, texture_uri=None)[source]

Parameters

arraysarray of dictionaries

Each dictionary has the data for one geometry arrays[‘position’]: binary array of vertex positions arrays[‘normal’]: binary array of vertex normals arrays[‘uv’]: binary array of vertex texture coordinates

(Not implemented yet)

arrays[‘bbox’]: geometry bounding box (numpy.array)

transformnumpy.array

World coordinates transformation flattend matrix

Returns

glTF : GlTF

to_array()[source]
class py3dtiles.Pnts[source]

Bases: TileContent

static from_array(array)[source]

Parameters

array : numpy.array

Returns

t : TileContent

static from_features(pd_type, cd_type, features)[source]

Parameters

dtypenumpy.dtype

Numpy description of a single feature

features : Feature[]

Returns

tile : TileContent

class py3dtiles.Tile(geometric_error=500, bounding_volume=None, refine_mode='ADD')[source]

Bases: Extendable

add_child(tile: Tile) None[source]
get_children() list[Tile][source]
Returns:

the recursive (across the children tree) list of the children tiles

get_content() TileContent[source]
get_content_uri() str[source]
get_direct_children() list[Tile][source]
get_refine_mode() str[source]
get_transform() list[float][source]
has_children() bool[source]
set_content(content: TileContent, force=True) None[source]
set_content_uri(uri: str) None[source]
set_refine_mode(mode: str) None[source]
set_transform(transform: list[float]) None[source]
Parameters:

transform – a flattened transformation matrix

Returns:

sync_bounding_volume_with_children() None[source]
to_dict() dict[source]
write_content(directory: Path) None[source]

Write (or overwrite) the tile _content_ to the directory specified as parameter and withing the relative filename designated by the tile’s content uri. Note that it is the responsibility of the owning TileSet to

  • set those uris

  • to explicitly invoke write_content() (this is to be opposed with the Tile attributes which get serialized when recursing on the TileSet attributes) :param directory: the target directory

class py3dtiles.TileContent[source]

Bases: object

save_as(path: Path)[source]
sync()[source]

Allow to synchronize headers with contents.

to_array()[source]
to_hex_str()[source]
class py3dtiles.TileContentReader[source]

Bases: object

static read_array(array: np.ndarray) TileContent | None[source]
static read_file(tile_path: Path) TileContent[source]
class py3dtiles.TileSet(geometric_error=500)[source]

Bases: Extendable

add_asset_extras(comment: str) None[source]
Parameters:

comment – the comment on original data, pre-processing, possible ownership to be added as asset extra.

set_transform(transform: List[float]) None[source]
Parameters:

transform – a flattened transformation matrix

Returns:

to_dict() dict[source]

Convert to json string possibly mentioning used schemas

to_json() str[source]
write_as_json(directory: Path) None[source]

Write the tileset as a JSON file. :param directory: the target directory name

write_to_directory(directory: Path) None[source]

Write (or overwrite), to the directory whose name is provided, the TileSet that is:

  • the tileset as a json file and

  • all the tiles content of the Tiles used by the Tileset.

Parameters:

directory – the target directory name

class py3dtiles.TriangleSoup[source]

Bases: object

static from_wkb_multipolygon(wkb, associated_data=None)[source]

Parameters

wkbstring

Well-Known Binary binary string describing a multipolygon

associated_dataarray

array of multipolygons containing data attached to the wkb parameter multipolygon. Must be the same size as wkb.

Returns

ts : TriangleSoup

get_bbox()[source]

Parameters

Returns

Array [[minX, minY, minZ],[maxX, maxY, maxZ]]

get_data_array(index)[source]

Parameters

index: int

The index of the associated data

Returns

Binary array of vertex data

get_normal_array()[source]

Parameters

Returns

Binary array of vertice normals

get_position_array()[source]

Parameters

Returns

Binary array of vertex positions

py3dtiles.convert_to_ecef(x, y, z, epsg_input)[source]

Subpackages

Submodules