OccPy_Riegl_IO
Occpy
Drivers for handling RIEGL rdbx and rxp files
Written for pylidar_tls_canopy by John Armston, University of Maryland Adapted for OccPy by Wout Cherlet, Ghent University
RDBFile
RIEGL RDBX point reader.
This class wraps cpp riegl_rdb reader to provide acces .rdbx files. Can apply transforms and filter points.
Source code in occpy/riegl_io.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 | |
__init__
__init__(filename, transform_file=None, pose_file=None, query_str=None)
Initialize RDBFile.
Parameters:
-
filename(str) –Path to .rdbx file.
-
transform_file(str, default:None) –Path to text file containing a 4x4 transform matrix. If provided, applied to coordinates.
-
pose_file(str, default:None) –Path to a JSON file with keys 'pitch', 'roll', 'yaw' (degrees) to construct a rotation matrix. Ignored if
transform_fileis provided. -
query_str(str or list of str, default:None) –Filter expression(s) applied to point attributes prior to aligning with pulses. See
run_queryfor syntax.
Source code in occpy/riegl_io.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | |
get_data
get_data(name)
Return a point attribute filtered by the current validity mask. Exits the process if the attribute is not available.
Parameters:
-
name(str) –Attribute name present in
self.points.
Returns:
-
ndarray–The requested attribute array, filtered by
self.points['valid'].
Source code in occpy/riegl_io.py
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | |
get_meta
get_meta(key)
Return individual metadata item by key.
Possible keys: 'riegl.pose_estimation', 'riegl.geo_tag', 'riegl.notch_filter', 'riegl.window_echo_correction', 'riegl.detection_probability', 'riegl.angular_notch_filter', 'riegl.pulse_position_modulation', 'riegl.noise_estimates', 'riegl.device', 'riegl.atmosphere', 'riegl.near_range_correction', 'riegl.time_base', 'riegl.scan_pattern', 'riegl.device_geometry', 'riegl.range_statistics', 'riegl.beam_geometry', 'riegl.reflectance_calculation', 'riegl.window_analysis', 'riegl.mta_settings', 'riegl.point_attribute_groups'
Parameters:
-
key(str) –Metadata key present in
self.meta.
Returns:
-
Any–The JSON-parsed value for the given key.
Source code in occpy/riegl_io.py
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 | |
read_file
read_file()
Read file and get global stats
Source code in occpy/riegl_io.py
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | |
run_query
run_query(points)
Build a boolean mask by evaluating the configured query over a structured array. - Supported operators: <, >, ==, >=, <=, !=. - Query can be a string or a list of strings; all are ANDed.
Parameters:
-
points(ndarray) –Structured array of point attributes as returned by riegl_rdb.
Returns:
-
numpy.ndarray of bool–Boolean mask of shape (N,)
Source code in occpy/riegl_io.py
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | |
RXPFile
RIEGL RXP point reader.
This class wraps cpp riegl_rxp reader to provide access to .rxp files. Can apply transforms and filter points and pulses.
Source code in occpy/riegl_io.py
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 | |
__init__
__init__(filename, transform_file=None, pose_file=None, query_str=None)
Initialize an RXPFile reader.
Parameters:
-
filename(str) –Path to .rxp file.
-
transform_file(str, default:None) –Path to text file containing a 4x4 transform matrix. If provided, applied to beam origins, directions, and points.
-
pose_file(str, default:None) –Path to a JSON file with keys 'pitch', 'roll', 'yaw' (degrees) to construct a rotation matrix. Ignored if
transform_fileis provided. -
query_str(str or list of str, default:None) –Filter expression(s) applied to point attributes prior to aligning with pulses. See
run_queryfor syntax.
Source code in occpy/riegl_io.py
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 | |
get_data
get_data(name, return_as_point_attribute=False)
Return a pulse or point attribute, optionally broadcast to points.
Parameters:
-
name(str) –Attribute name present in
self.pulsesorself.points. -
return_as_point_attribute(bool, default:False) –When
Trueandnameis a pulse attribute, repeat values per target count and return a point-aligned array. Ignored for point attributes.
Returns:
-
ndarray–The attribute array
Source code in occpy/riegl_io.py
393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 | |
get_points_by_pulse
get_points_by_pulse(names)
Reshape data as a number of pulses by max_target_count array Multiple point attributes are handled using a structured array
Parameters:
-
names(list of str) –Point attribute names to include.
Source code in occpy/riegl_io.py
365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 | |
read_file
read_file()
Read file and get global stats
Source code in occpy/riegl_io.py
283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 | |
run_query
run_query(points)
Build a boolean mask by evaluating the configured query over a structured array. - Supported operators: <, >, ==, >=, <=, !=. - Query can be a string or a list of strings; all are ANDed.
Parameters:
-
points(ndarray) –Structured array of point attributes as returned by riegl_rdb.
Returns:
-
numpy.ndarray of bool–Boolean mask of shape (N,)
Source code in occpy/riegl_io.py
244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 | |
apply_transformation
apply_transformation(x, y, z, size, transform_matrix, translate=False)
Apply a 4x4 transformation to 3D coordinates.
Parameters:
-
x(array - like) –Coordinate components of equal length N.
-
y(array - like) –Coordinate components of equal length N.
-
z(array - like) –Coordinate components of equal length N.
-
size(int) –Number of points
-
transform_matrix(ndarray) –4x4 transform matrix.
-
translate(bool, default:False) –If True, apply translation on top of rotation.
Returns:
-
tuple of numpy.ndarray–Transformed (x, y, z) arrays.
Source code in occpy/riegl_io.py
474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 | |
calc_transform_matrix
calc_transform_matrix(pitch, roll, yaw)
Construct a 4x4 rotation matrix from pitch, roll, yaw.
Parameters:
-
pitch(float) –Pitch angle in degrees.
-
roll(float) –Roll angle in degrees.
-
yaw(float) –Yaw angle in degrees. If NaN, treated as 0.0.
Returns:
-
ndarray–4x4 rotation matrix.
Source code in occpy/riegl_io.py
428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 | |
read_transform_file
read_transform_file(fn)
Read a 4x4 transform matrix from a text file.
Parameters:
-
fn(str) –Path to the transform file (whitespace-separated floats, row-major).
Returns:
-
ndarray–4x4 transform matrix (transposed to match expected orientation).
Source code in occpy/riegl_io.py
530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 | |
reindex_targets
reindex_targets(target_index, target_count, scanline, scanline_idx)
Reindex the target index and count Assumes the input data are time-sequential
Parameters:
-
target_index(ndarray) –Original per-point target index array of shape (N,).
-
target_count(ndarray) –Per-point target count array of shape (N,).
-
scanline(ndarray) –Per-point scanline identifier of shape (N,).
-
scanline_idx(ndarray) –Per-point scanline index within the scanline of shape (N,).
Returns:
-
tuple of numpy.ndarray–new_target_index : numpy.ndarray Reindexed target indices, same shape and dtype as
target_index. new_target_count : numpy.ndarray Recomputed per-point target counts, same shape and dtype astarget_count.
Source code in occpy/riegl_io.py
549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 | |
xyz2rza
xyz2rza(x, y, z)
Convert Cartesian coordinates to spherical (range, zenith, azimuth).
Parameters:
-
x(array - like) –Cartesian components.
-
y(array - like) –Cartesian components.
-
z(array - like) –Cartesian components.
Returns:
-
tuple of numpy.ndarray–r : range (radius) theta : zenith angle in radians (0 at +Z) phi : azimuth angle in radians, wrapped to [0, 2π).
Source code in occpy/riegl_io.py
506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 | |