-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add function for extract bounding box with pdal
- Loading branch information
1 parent
82402f2
commit 574ca49
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# -*- coding: utf-8 -*- | ||
""" Utils PDAL | ||
""" | ||
import pdal | ||
|
||
|
||
def read_las_file(input_las: str): | ||
"""Read a las file and put it in an array""" | ||
pipeline = pdal.Pipeline() | pdal.Reader.las(filename=input_las, nosrs=True) | ||
pipeline.execute() | ||
return pipeline.arrays[0] | ||
|
||
|
||
def get_info_from_las(points): | ||
"""Get info from a las to put it in an array""" | ||
pipeline = pdal.Filter.stats().pipeline(points) | ||
pipeline.execute() | ||
return pipeline.metadata | ||
|
||
|
||
def get_bounds_from_las(in_las: str): | ||
"""Get bounds=([minx,maxx],[miny,maxy]) from las file | ||
Args: | ||
in_las (str): Path to the input LAS/LAZ file | ||
Returns: | ||
tuple : Bounds = ([minx,maxx],[miny,maxy]) from las file | ||
""" | ||
metadata = get_info_from_las(read_las_file(in_las)) | ||
xmin = metadata["metadata"]["filters.stats"]["bbox"]["native"]["bbox"]["minx"] | ||
xmax = metadata["metadata"]["filters.stats"]["bbox"]["native"]["bbox"]["maxx"] | ||
ymin = metadata["metadata"]["filters.stats"]["bbox"]["native"]["bbox"]["miny"] | ||
ymax = metadata["metadata"]["filters.stats"]["bbox"]["native"]["bbox"]["maxy"] | ||
return ([xmin, xmax], [ymin, ymax]) |