RDB 2
Main Page
Related Pages
Namespaces
Classes
Files
Examples
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
rdb-example-06-database-stat.py
1
#!/usr/bin/env python3
2
# -*- coding: utf-8 -*-
3
#
4
#*******************************************************************************
5
#
6
# Copyright 2023 RIEGL Laser Measurement Systems
7
#
8
# Licensed under the Apache License, Version 2.0 (the "License");
9
# you may not use this file except in compliance with the License.
10
# You may obtain a copy of the License at
11
#
12
# http://www.apache.org/licenses/LICENSE-2.0
13
#
14
# Unless required by applicable law or agreed to in writing, software
15
# distributed under the License is distributed on an "AS IS" BASIS,
16
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
# See the License for the specific language governing permissions and
18
# limitations under the License.
19
#
20
# SPDX-License-Identifier: Apache-2.0
21
#
22
#*******************************************************************************
23
#
24
"""
25
rdb-example-06-database-stat.py
26
27
This example shows how to open an existing database and output some
28
information about the database like the list of point attributes,
29
number of points and point cloud extents.
30
"""
31
32
import
riegl.rdb
33
34
# Open existing database using default settings
35
with riegl.rdb.rdb_open(
"pointcloud.rdbx"
)
as
rdb:
36
print(
"META DATA:"
)
37
for
key
in
rdb.meta_data:
38
print(f
" Name: {key}"
)
39
print(f
" Value: {rdb.meta_data[key]}"
)
40
print(
"-"
* 80)
41
# to write text: rdb.meta_data["my_text"] = "Example"
42
# to write JSON: rdb.meta_data["my_json"] = json.dumps({"name": "value"})
43
44
print(
"POINT ATTRIBUTES:"
)
45
for
attribute
in
rdb.point_attributes.values():
46
print(f
" Name: {attribute.name}"
)
47
print(f
" Title: {attribute.title}"
)
48
print(f
" Description: {attribute.description}"
)
49
print(f
" Unit: {attribute.unit_symbol}"
)
50
print(f
" Length: {attribute.length}"
)
51
print(f
" Resolution: {attribute.resolution}"
)
52
print(f
" MinimumValue: {attribute.minimum_value}"
)
53
print(f
" MaximumValue: {attribute.maximum_value}"
)
54
print(f
" DefaultValue: {attribute.default_value}"
)
55
print(
"-"
* 80)
56
57
with rdb.stat
as
stat:
58
print(
"POINT CLOUD STATISTICS:"
)
59
print(f
" Total point count: {stat.point_count_total}"
)
60
print(f
" Minimum X, Y, Z: {stat.minimum('riegl.xyz')}"
)
61
print(f
" Maximum X, Y, Z: {stat.maximum('riegl.xyz')}"
)
62
63
print(
"PRIMARY INDEX STATISTICS:"
)
64
leaves = [
65
(
66
leaf.point_count_node,
67
leaf.minimum(
"riegl.xyz"
),
68
leaf.maximum(
"riegl.xyz"
)
69
)
70
for
leaf
in
stat.leaves
71
]
72
print(f
" Number of leaf nodes: {len(leaves)}"
)
73
print(
" Point count, minimum and maximum coordinates for all leaves:"
)
74
for
leaf
in
leaves:
75
print(f
" {leaf[0]}, {leaf[1]} - {leaf[2]}"
)
Generated on Thu Nov 30 2023 13:50:36 for RDB 2 by
1.8.6