25 rdb-example-03-select-points.py 27 This example shows different ways to open an existing database and query 36 Load points that meet filter criteria and print them point-wise. 37 To load all points instead, simply remove the filter string or 38 specify 'None' (the constant, not the string "None"). 41 with riegl.rdb.rdb_open(
"pointcloud.rdbx")
as rdb:
42 for point
in rdb.points(
43 "(riegl.xyz[2] > 5) && (riegl.reflectance > 35)" 45 print(f
"{point['riegl.id']}, {point['riegl.xyz']}, {point['riegl.reflectance']}")
50 Similar to example A, but instead of loading all point attributes 51 we specify the names of the point attributes to load and print. 54 with riegl.rdb.rdb_open(
"pointcloud.rdbx")
as rdb:
55 for point
in rdb.points(
56 "(riegl.xyz[2] > 5) && (riegl.reflectance > 35)",
57 [
"riegl.id",
"riegl.xyz",
"riegl.reflectance"]
59 print(f
"{point['riegl.id']}, {point['riegl.xyz']}, {point['riegl.reflectance']}")
64 Similar to example A, but instead of loading point-by-point, we 65 load points chunk-wise and access the attributes via arrays. 66 Please note that we use select() instead of points() this time. 69 with riegl.rdb.rdb_open(
"pointcloud.rdbx")
as rdb:
70 for points
in rdb.select(
71 "(riegl.xyz[2] > 5) && (riegl.reflectance > 35)",
74 print(points[
"riegl.id"])
75 print(points[
"riegl.xyz"])
76 print(points[
"riegl.reflectance"])
81 This example shows the most flexible way as known from the RDB C++ API. 82 This time we manually create buffers for the point attributes read from 83 the point cloud and iterate the point cloud chunk-wise. 86 with riegl.rdb.rdb_open(
"pointcloud.rdbx")
as rdb:
88 chunk_size = 100 * 1000
91 buffer_xyz = riegl.rdb.AttributeBuffer(
92 rdb.point_attributes[
"riegl.xyz"], chunk_size
94 buffer_reflectance = riegl.rdb.AttributeBuffer(
95 rdb.point_attributes[
"riegl.reflectance"], chunk_size
99 with rdb.select()
as query:
101 query.bind(buffer_xyz)
102 query.bind(buffer_reflectance)
105 while point_count > 0:
106 point_count = query.next(chunk_size)
111 for i
in range(point_count):
112 print(f
"{buffer_xyz[i]}, {buffer_reflectance[i]}")
117 This example shows how to read points into a Pandas DataFrame. 120 frame = riegl.rdb.rdb_to_pandas(
121 pointcloud=riegl.rdb.rdb_open(
"pointcloud.rdbx"),
122 attributes=(
"riegl.id",
"riegl.xyz",
"riegl.reflectance"),
123 selection=
"riegl.id <= 10" 129 if __name__ ==
"__main__":