| RDB 2

rdb-example-10-attribute-groups.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 #
4 #*******************************************************************************
5 #
6 # Copyright 2025 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-10-attribute-groups.py
26
27 This example shows how to open an existing database and output the
28 point attribute group names and the point attributes in each group.
29
30 Example output:
31
32 Coordinates/Vectors:
33 - XYZ (riegl.xyz)
34 Time:
35 - Timestamp (riegl.timestamp)
36 Primary Attributes:
37 - Reflectance (riegl.reflectance)
38 - Amplitude (riegl.amplitude)
39 - Deviation (riegl.deviation)
40 - True Color (riegl.rgba)
41 - Target Index (riegl.target_index)
42 - Target Count (riegl.target_count)
43 Secondary Attributes:
44 - Mirror Facet (riegl.mirror_facet)
45 - PID (riegl.id)
46 Other Attributes:
47 - Selected (riegl.selected)
48 - Visible (riegl.visible)
49 """
50
51 import riegl.rdb
52
53 # Open existing database using default settings
54 with riegl.rdb.rdb_open("pointcloud.rdbx") as rdb:
55 current_group = None
56 for attribute in rdb.point_attributes.values():
57 # Query point attribute group
58 group, index = rdb.point_attributes.group(attribute.name)
59 if current_group != group: # print name of new group:
60 print(group)
61 current_group = group
62
63 # Print point attribute details
64 print(f" - {attribute.title} ({attribute.name})")