ign-pdal-tools 1.7.5__tar.gz → 1.7.7__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {ign_pdal_tools-1.7.5 → ign_pdal_tools-1.7.7}/PKG-INFO +2 -2
- {ign_pdal_tools-1.7.5 → ign_pdal_tools-1.7.7}/ign_pdal_tools.egg-info/PKG-INFO +2 -2
- {ign_pdal_tools-1.7.5 → ign_pdal_tools-1.7.7}/ign_pdal_tools.egg-info/SOURCES.txt +2 -0
- {ign_pdal_tools-1.7.5 → ign_pdal_tools-1.7.7}/pdaltools/_version.py +1 -1
- ign_pdal_tools-1.7.7/pdaltools/add_points_in_pointcloud.py +170 -0
- {ign_pdal_tools-1.7.5 → ign_pdal_tools-1.7.7}/pdaltools/las_info.py +18 -0
- ign_pdal_tools-1.7.7/test/test_add_points_in_pointcloud.py +172 -0
- {ign_pdal_tools-1.7.5 → ign_pdal_tools-1.7.7}/test/test_las_info.py +14 -0
- {ign_pdal_tools-1.7.5 → ign_pdal_tools-1.7.7}/LICENSE.md +0 -0
- {ign_pdal_tools-1.7.5 → ign_pdal_tools-1.7.7}/README.md +0 -0
- {ign_pdal_tools-1.7.5 → ign_pdal_tools-1.7.7}/ign_pdal_tools.egg-info/dependency_links.txt +0 -0
- {ign_pdal_tools-1.7.5 → ign_pdal_tools-1.7.7}/ign_pdal_tools.egg-info/top_level.txt +0 -0
- {ign_pdal_tools-1.7.5 → ign_pdal_tools-1.7.7}/pdaltools/add_points_in_las.py +0 -0
- {ign_pdal_tools-1.7.5 → ign_pdal_tools-1.7.7}/pdaltools/color.py +0 -0
- {ign_pdal_tools-1.7.5 → ign_pdal_tools-1.7.7}/pdaltools/las_add_buffer.py +0 -0
- {ign_pdal_tools-1.7.5 → ign_pdal_tools-1.7.7}/pdaltools/las_clip.py +0 -0
- {ign_pdal_tools-1.7.5 → ign_pdal_tools-1.7.7}/pdaltools/las_merge.py +0 -0
- {ign_pdal_tools-1.7.5 → ign_pdal_tools-1.7.7}/pdaltools/las_remove_dimensions.py +0 -0
- {ign_pdal_tools-1.7.5 → ign_pdal_tools-1.7.7}/pdaltools/pcd_info.py +0 -0
- {ign_pdal_tools-1.7.5 → ign_pdal_tools-1.7.7}/pdaltools/replace_attribute_in_las.py +0 -0
- {ign_pdal_tools-1.7.5 → ign_pdal_tools-1.7.7}/pdaltools/standardize_format.py +0 -0
- {ign_pdal_tools-1.7.5 → ign_pdal_tools-1.7.7}/pdaltools/unlock_file.py +0 -0
- {ign_pdal_tools-1.7.5 → ign_pdal_tools-1.7.7}/pyproject.toml +0 -0
- {ign_pdal_tools-1.7.5 → ign_pdal_tools-1.7.7}/setup.cfg +0 -0
- {ign_pdal_tools-1.7.5 → ign_pdal_tools-1.7.7}/test/test_add_points_in_las.py +0 -0
- {ign_pdal_tools-1.7.5 → ign_pdal_tools-1.7.7}/test/test_color.py +0 -0
- {ign_pdal_tools-1.7.5 → ign_pdal_tools-1.7.7}/test/test_las_add_buffer.py +0 -0
- {ign_pdal_tools-1.7.5 → ign_pdal_tools-1.7.7}/test/test_las_clip.py +0 -0
- {ign_pdal_tools-1.7.5 → ign_pdal_tools-1.7.7}/test/test_las_merge.py +0 -0
- {ign_pdal_tools-1.7.5 → ign_pdal_tools-1.7.7}/test/test_las_remove_dimensions.py +0 -0
- {ign_pdal_tools-1.7.5 → ign_pdal_tools-1.7.7}/test/test_pcd_info.py +0 -0
- {ign_pdal_tools-1.7.5 → ign_pdal_tools-1.7.7}/test/test_replace_attribute_in_las.py +0 -0
- {ign_pdal_tools-1.7.5 → ign_pdal_tools-1.7.7}/test/test_standardize_format.py +0 -0
- {ign_pdal_tools-1.7.5 → ign_pdal_tools-1.7.7}/test/test_unlock.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
2
|
Name: ign-pdal-tools
|
|
3
|
-
Version: 1.7.
|
|
3
|
+
Version: 1.7.7
|
|
4
4
|
Summary: Library for common LAS files manipulation with PDAL
|
|
5
5
|
Author-email: Guillaume Liegard <guillaume.liegard@ign.fr>
|
|
6
6
|
Description-Content-Type: text/markdown
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
2
|
Name: ign-pdal-tools
|
|
3
|
-
Version: 1.7.
|
|
3
|
+
Version: 1.7.7
|
|
4
4
|
Summary: Library for common LAS files manipulation with PDAL
|
|
5
5
|
Author-email: Guillaume Liegard <guillaume.liegard@ign.fr>
|
|
6
6
|
Description-Content-Type: text/markdown
|
|
@@ -7,6 +7,7 @@ ign_pdal_tools.egg-info/dependency_links.txt
|
|
|
7
7
|
ign_pdal_tools.egg-info/top_level.txt
|
|
8
8
|
pdaltools/_version.py
|
|
9
9
|
pdaltools/add_points_in_las.py
|
|
10
|
+
pdaltools/add_points_in_pointcloud.py
|
|
10
11
|
pdaltools/color.py
|
|
11
12
|
pdaltools/las_add_buffer.py
|
|
12
13
|
pdaltools/las_clip.py
|
|
@@ -18,6 +19,7 @@ pdaltools/replace_attribute_in_las.py
|
|
|
18
19
|
pdaltools/standardize_format.py
|
|
19
20
|
pdaltools/unlock_file.py
|
|
20
21
|
test/test_add_points_in_las.py
|
|
22
|
+
test/test_add_points_in_pointcloud.py
|
|
21
23
|
test/test_color.py
|
|
22
24
|
test/test_las_add_buffer.py
|
|
23
25
|
test/test_las_clip.py
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
|
|
3
|
+
import geopandas as gpd
|
|
4
|
+
import laspy
|
|
5
|
+
import numpy as np
|
|
6
|
+
from pyproj import CRS
|
|
7
|
+
from pyproj.exceptions import CRSError
|
|
8
|
+
from shapely.geometry import box
|
|
9
|
+
|
|
10
|
+
from pdaltools.las_info import get_epsg_from_las, get_tile_origin_using_header_info
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def parse_args(argv=None):
|
|
14
|
+
parser = argparse.ArgumentParser("Add points from GeoJSON in LIDAR tile")
|
|
15
|
+
parser.add_argument("--input_geojson", "-ig", type=str, required=True, help="Input GeoJSON file")
|
|
16
|
+
parser.add_argument("--input_las", "-i", type=str, required=True, help="Input las file")
|
|
17
|
+
parser.add_argument("--output_las", "-o", type=str, required=True, default="", help="Output las file")
|
|
18
|
+
parser.add_argument(
|
|
19
|
+
"--virtual_points_classes",
|
|
20
|
+
"-c",
|
|
21
|
+
type=int,
|
|
22
|
+
default=66,
|
|
23
|
+
help="classification value to assign to the added virtual points",
|
|
24
|
+
)
|
|
25
|
+
parser.add_argument(
|
|
26
|
+
"--spatial_ref",
|
|
27
|
+
type=str,
|
|
28
|
+
required=False,
|
|
29
|
+
help="spatial reference for the writer",
|
|
30
|
+
)
|
|
31
|
+
parser.add_argument(
|
|
32
|
+
"--tile_width",
|
|
33
|
+
type=int,
|
|
34
|
+
default=1000,
|
|
35
|
+
help="width of tiles in meters",
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
return parser.parse_args(argv)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def get_tile_bbox(input_las, tile_width=1000) -> tuple:
|
|
42
|
+
"""
|
|
43
|
+
Get the theoretical bounding box (xmin, ymin, xmax, ymax) of a LIDAR tile
|
|
44
|
+
using its origin and the predefined tile width.
|
|
45
|
+
|
|
46
|
+
Args:
|
|
47
|
+
input_las (str): Path to the LIDAR `.las/.laz` file.
|
|
48
|
+
tile_width (int): Width of the tile in meters (default: 1000).
|
|
49
|
+
|
|
50
|
+
Returns:
|
|
51
|
+
tuple: Bounding box as (xmin, ymin, xmax, ymax).
|
|
52
|
+
"""
|
|
53
|
+
origin_x, origin_y = get_tile_origin_using_header_info(input_las)
|
|
54
|
+
bbox = (origin_x, origin_y - tile_width, origin_x + tile_width, origin_y)
|
|
55
|
+
return bbox
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def clip_3d_points_to_tile(input_points: str, input_las: str, crs: str, tile_width: int) -> gpd.GeoDataFrame:
|
|
59
|
+
"""
|
|
60
|
+
Add points from a GeoJSON file in the LIDAR's tile.
|
|
61
|
+
|
|
62
|
+
Args:
|
|
63
|
+
input_points (str): Path to the input GeoJSON file with 3D points.
|
|
64
|
+
input_las (str): Path to the LIDAR `.las/.laz` file.
|
|
65
|
+
crs (str): CRS of the data.
|
|
66
|
+
tile_width (int): Width of the tile in meters (default: 1000).
|
|
67
|
+
|
|
68
|
+
Return:
|
|
69
|
+
gpd.GeoDataFrame: Points 2d with "Z" value
|
|
70
|
+
"""
|
|
71
|
+
# Compute the bounding box of the LIDAR tile
|
|
72
|
+
tile_bbox = get_tile_bbox(input_las, tile_width)
|
|
73
|
+
|
|
74
|
+
# Read the input GeoJSON with 3D points
|
|
75
|
+
points_gdf = gpd.read_file(input_points)
|
|
76
|
+
|
|
77
|
+
if crs:
|
|
78
|
+
points_gdf = points_gdf.to_crs(crs)
|
|
79
|
+
|
|
80
|
+
# Create a polygon from the bounding box
|
|
81
|
+
bbox_polygon = box(*tile_bbox)
|
|
82
|
+
|
|
83
|
+
# Clip the points to the bounding box
|
|
84
|
+
clipped_points = points_gdf[points_gdf.intersects(bbox_polygon)].copy()
|
|
85
|
+
|
|
86
|
+
return clipped_points
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def add_points_to_las(
|
|
90
|
+
input_points_with_z: gpd.GeoDataFrame, input_las: str, output_las: str, crs: str, virtual_points_classes=66
|
|
91
|
+
):
|
|
92
|
+
"""Add points (3D points in LAZ format) by LIDAR tiles (tiling file)
|
|
93
|
+
|
|
94
|
+
Args:
|
|
95
|
+
input_points_with_z(gpd.GeoDataFrame): geometry columns (2D points) as encoded to WKT.
|
|
96
|
+
input_las (str): Path to the LIDAR tiles (LAZ).
|
|
97
|
+
output_las (str): Path to save the updated LIDAR file (LAS/LAZ format).
|
|
98
|
+
crs (str): CRS of the data.
|
|
99
|
+
virtual_points_classes (int): The classification value to assign to those virtual points (default: 66).
|
|
100
|
+
"""
|
|
101
|
+
# Check if input points are empty
|
|
102
|
+
if input_points_with_z.empty:
|
|
103
|
+
raise ValueError("No points to add. The input GeoDataFrame is empty.")
|
|
104
|
+
|
|
105
|
+
# Extract XYZ coordinates and additional attribute (classification)
|
|
106
|
+
x_coords = input_points_with_z.geometry.x
|
|
107
|
+
y_coords = input_points_with_z.geometry.y
|
|
108
|
+
z_coords = input_points_with_z.RecupZ
|
|
109
|
+
classes = virtual_points_classes * np.ones(len(input_points_with_z.index))
|
|
110
|
+
|
|
111
|
+
with laspy.open(input_las, mode="r") as las:
|
|
112
|
+
las_data = las.read()
|
|
113
|
+
header = las.header
|
|
114
|
+
|
|
115
|
+
if not header:
|
|
116
|
+
header = laspy.LasHeader(point_format=8, version="1.4")
|
|
117
|
+
if crs:
|
|
118
|
+
try:
|
|
119
|
+
crs_obj = CRS.from_user_input(crs) # Convert to a pyproj.CRS object
|
|
120
|
+
except CRSError:
|
|
121
|
+
raise ValueError(f"Invalid CRS: {crs}")
|
|
122
|
+
header.add_crs(crs_obj)
|
|
123
|
+
|
|
124
|
+
# Append new points
|
|
125
|
+
new_x = np.concatenate([las_data.x, x_coords])
|
|
126
|
+
new_y = np.concatenate([las_data.y, y_coords])
|
|
127
|
+
new_z = np.concatenate([las_data.z, z_coords])
|
|
128
|
+
new_classes = np.concatenate([las_data.classification, classes])
|
|
129
|
+
|
|
130
|
+
updated_las = laspy.LasData(header)
|
|
131
|
+
updated_las.x = new_x
|
|
132
|
+
updated_las.y = new_y
|
|
133
|
+
updated_las.z = new_z
|
|
134
|
+
updated_las.classification = new_classes
|
|
135
|
+
|
|
136
|
+
with laspy.open(output_las, mode="w", header=header, do_compress=True) as writer:
|
|
137
|
+
writer.write_points(updated_las.points)
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
def add_points_from_geojson_to_las(
|
|
141
|
+
input_geojson: str, input_las: str, output_las: str, virtual_points_classes: int, spatial_ref: str, tile_width: int
|
|
142
|
+
):
|
|
143
|
+
"""Add points with Z value(GeoJSON format) by LIDAR tiles (tiling file)
|
|
144
|
+
|
|
145
|
+
Args:
|
|
146
|
+
input_geojson (str): Path to the input GeoJSON file with 3D points.
|
|
147
|
+
input_las (str): Path to the LIDAR `.las/.laz` file.
|
|
148
|
+
output_las (str): Path to save the updated LIDAR file (LAS/LAZ format).
|
|
149
|
+
virtual_points_classes (int): The classification value to assign to those virtual points (default: 66).
|
|
150
|
+
spatial_ref (str): CRS of the data.
|
|
151
|
+
tile_width (int): Width of the tile in meters (default: 1000).
|
|
152
|
+
|
|
153
|
+
Raises:
|
|
154
|
+
RuntimeError: If the input LAS file has no valid EPSG code.
|
|
155
|
+
"""
|
|
156
|
+
if not spatial_ref:
|
|
157
|
+
spatial_ref = get_epsg_from_las(input_las)
|
|
158
|
+
if spatial_ref is None:
|
|
159
|
+
raise RuntimeError(f"LAS file {input_las} does not have a valid EPSG code.")
|
|
160
|
+
|
|
161
|
+
# Clip points from GeoJSON by LIDAR tile
|
|
162
|
+
points_clipped = clip_3d_points_to_tile(input_geojson, input_las, spatial_ref, tile_width)
|
|
163
|
+
|
|
164
|
+
# Add points by LIDAR tile and save the result
|
|
165
|
+
add_points_to_las(points_clipped, input_las, output_las, spatial_ref, virtual_points_classes)
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
if __name__ == "__main__":
|
|
169
|
+
args = parse_args()
|
|
170
|
+
add_points_from_geojson_to_las(**vars(args))
|
|
@@ -3,6 +3,7 @@ import logging
|
|
|
3
3
|
import os
|
|
4
4
|
from typing import Dict, Tuple
|
|
5
5
|
|
|
6
|
+
import laspy
|
|
6
7
|
import osgeo.osr as osr
|
|
7
8
|
import pdal
|
|
8
9
|
|
|
@@ -211,3 +212,20 @@ def get_writer_parameters_from_reader_metadata(metadata: Dict, a_srs=None) -> Di
|
|
|
211
212
|
"a_srs": a_srs if a_srs else reader_metadata["comp_spatialreference"],
|
|
212
213
|
}
|
|
213
214
|
return params
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
def get_epsg_from_las(filename: str) -> str:
|
|
218
|
+
"""Extract EPSG code from LAS file metadata and return as 'EPSG:XXXX' format.
|
|
219
|
+
|
|
220
|
+
Args:
|
|
221
|
+
filename (str): full path of file for which to get the bounding box
|
|
222
|
+
|
|
223
|
+
Returns:
|
|
224
|
+
str : CRS's value of the data in 'EPSG:XXXX' format, or None if not found.
|
|
225
|
+
"""
|
|
226
|
+
with laspy.open(filename) as las:
|
|
227
|
+
crs = las.header.parse_crs()
|
|
228
|
+
if crs is None:
|
|
229
|
+
return None # Return None if CRS is not defined
|
|
230
|
+
epsg_code = crs.to_epsg()
|
|
231
|
+
return f"EPSG:{epsg_code}" if epsg_code else None
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import inspect
|
|
2
|
+
import os
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
import pdal
|
|
6
|
+
import pytest
|
|
7
|
+
|
|
8
|
+
from pdaltools import add_points_in_pointcloud
|
|
9
|
+
|
|
10
|
+
TEST_PATH = os.path.dirname(os.path.abspath(__file__))
|
|
11
|
+
TMP_PATH = os.path.join(TEST_PATH, "data/output")
|
|
12
|
+
DATA_LIDAR_PATH = os.path.join(TEST_PATH, "data/decimated_laz")
|
|
13
|
+
DATA_POINTS_PATH = os.path.join(TEST_PATH, "data/points_3d")
|
|
14
|
+
|
|
15
|
+
INPUT_FILE = os.path.join(DATA_LIDAR_PATH, "test_semis_2023_0292_6833_LA93_IGN69.laz")
|
|
16
|
+
INPUT_POINTS = os.path.join(DATA_POINTS_PATH, "Points_virtuels_0292_6833.geojson")
|
|
17
|
+
OUTPUT_FILE = os.path.join(TMP_PATH, "test_semis_2023_0292_6833_LA93_IGN69.laz")
|
|
18
|
+
|
|
19
|
+
INPUT_FILE_SMALL = os.path.join(DATA_LIDAR_PATH, "test_semis_2021_0382_6565_LA93_IGN69.laz")
|
|
20
|
+
INPUT_POINTS_SMALL = os.path.join(DATA_POINTS_PATH, "Points_virtuels_0382_6565.geojson")
|
|
21
|
+
OUTPUT_FILE_SMALL = os.path.join(TMP_PATH, "test_semis_2021_0382_6565_LA93_IGN69.laz")
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def setup_module(module):
|
|
25
|
+
os.makedirs("test/data/output", exist_ok=True)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def test_get_tile_bbox():
|
|
29
|
+
bbox = add_points_in_pointcloud.get_tile_bbox(INPUT_FILE, 1000)
|
|
30
|
+
assert bbox == (292000.0, 6832000.0, 293000.0, 6833000.0) # check the bbox from LIDAR tile
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def test_clip_3d_points_to_tile():
|
|
34
|
+
# With EPSG
|
|
35
|
+
points_clipped = add_points_in_pointcloud.clip_3d_points_to_tile(INPUT_POINTS, INPUT_FILE, "EPSG:2154", 1000)
|
|
36
|
+
assert len(points_clipped) == 678 # chech the entity's number of points
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def test_clip_3d_points_to_tile_from_epsg_none():
|
|
40
|
+
points_clipped = add_points_in_pointcloud.clip_3d_points_to_tile(INPUT_POINTS, INPUT_FILE, None, 1000)
|
|
41
|
+
assert len(points_clipped) == 678 # chech the entity's number of points
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def test_add_line_to_lidar():
|
|
45
|
+
# Ensure the output file doesn't exist before the test
|
|
46
|
+
if Path(OUTPUT_FILE).exists():
|
|
47
|
+
os.remove(OUTPUT_FILE)
|
|
48
|
+
|
|
49
|
+
points_clipped = add_points_in_pointcloud.clip_3d_points_to_tile(INPUT_POINTS, INPUT_FILE, "EPSG:2154", 1000)
|
|
50
|
+
|
|
51
|
+
add_points_in_pointcloud.add_points_to_las(points_clipped, INPUT_FILE, OUTPUT_FILE, "EPSG:2154", 68)
|
|
52
|
+
assert Path(OUTPUT_FILE).exists() # check output exists
|
|
53
|
+
|
|
54
|
+
# Filter pointcloud by classes
|
|
55
|
+
pipeline = (
|
|
56
|
+
pdal.Reader.las(filename=OUTPUT_FILE, nosrs=True)
|
|
57
|
+
| pdal.Filter.range(
|
|
58
|
+
limits="Classification[68:68]",
|
|
59
|
+
)
|
|
60
|
+
| pdal.Filter.stats()
|
|
61
|
+
)
|
|
62
|
+
pipeline.execute()
|
|
63
|
+
metadata = pipeline.metadata
|
|
64
|
+
# Count the pointcloud's number from classe "68"
|
|
65
|
+
point_count = metadata["metadata"]["filters.stats"]["statistic"][0]["count"]
|
|
66
|
+
assert point_count == 678
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def test_add_line_to_lidar_from_epsg_none():
|
|
70
|
+
# Ensure the output file doesn't exist before the test
|
|
71
|
+
if Path(OUTPUT_FILE).exists():
|
|
72
|
+
os.remove(OUTPUT_FILE)
|
|
73
|
+
|
|
74
|
+
points_clipped = add_points_in_pointcloud.clip_3d_points_to_tile(INPUT_POINTS, INPUT_FILE, None, 1000)
|
|
75
|
+
|
|
76
|
+
add_points_in_pointcloud.add_points_to_las(points_clipped, INPUT_FILE, OUTPUT_FILE, None, 68)
|
|
77
|
+
assert Path(OUTPUT_FILE).exists() # check output exists
|
|
78
|
+
|
|
79
|
+
# Filter pointcloud by classes
|
|
80
|
+
pipeline = (
|
|
81
|
+
pdal.Reader.las(filename=OUTPUT_FILE, nosrs=True)
|
|
82
|
+
| pdal.Filter.range(
|
|
83
|
+
limits="Classification[68:68]",
|
|
84
|
+
)
|
|
85
|
+
| pdal.Filter.stats()
|
|
86
|
+
)
|
|
87
|
+
pipeline.execute()
|
|
88
|
+
metadata = pipeline.metadata
|
|
89
|
+
# Count the pointcloud's number from classe "68"
|
|
90
|
+
point_count = metadata["metadata"]["filters.stats"]["statistic"][0]["count"]
|
|
91
|
+
assert point_count == 678
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def test_get_tile_bbox_small():
|
|
95
|
+
# Tile is not complete (NOT 1km * 1km)
|
|
96
|
+
bbox = add_points_in_pointcloud.get_tile_bbox(INPUT_FILE_SMALL, 1000)
|
|
97
|
+
assert bbox == (382000.0, 6564000.0, 383000.0, 6565000.0) # return BBOX 1km * 1km
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def test_add_line_to_lidar_small():
|
|
101
|
+
# Ensure the output file doesn't exist before the test
|
|
102
|
+
if Path(OUTPUT_FILE_SMALL).exists():
|
|
103
|
+
os.remove(OUTPUT_FILE_SMALL)
|
|
104
|
+
|
|
105
|
+
# Tile is not complete (NOT 1km * 1km)
|
|
106
|
+
points_clipped = add_points_in_pointcloud.clip_3d_points_to_tile(
|
|
107
|
+
INPUT_POINTS_SMALL, INPUT_FILE_SMALL, "EPSG:2154", 1000
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
add_points_in_pointcloud.add_points_to_las(points_clipped, INPUT_FILE_SMALL, OUTPUT_FILE_SMALL, "EPSG:2154", 68)
|
|
111
|
+
assert Path(OUTPUT_FILE).exists() # check output exists
|
|
112
|
+
|
|
113
|
+
# Filter pointcloud by classes
|
|
114
|
+
pipeline = (
|
|
115
|
+
pdal.Reader.las(filename=OUTPUT_FILE_SMALL, nosrs=True)
|
|
116
|
+
| pdal.Filter.range(
|
|
117
|
+
limits="Classification[68:68]",
|
|
118
|
+
)
|
|
119
|
+
| pdal.Filter.stats()
|
|
120
|
+
)
|
|
121
|
+
pipeline.execute()
|
|
122
|
+
metadata = pipeline.metadata
|
|
123
|
+
# Count the pointcloud's number from classe "68"
|
|
124
|
+
point_count = metadata["metadata"]["filters.stats"]["statistic"][0]["count"]
|
|
125
|
+
assert point_count == 186
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
def test_add_points_from_geojson_to_las():
|
|
129
|
+
# Ensure the output file doesn't exist before the test
|
|
130
|
+
if Path(OUTPUT_FILE).exists():
|
|
131
|
+
os.remove(OUTPUT_FILE)
|
|
132
|
+
|
|
133
|
+
add_points_in_pointcloud.add_points_from_geojson_to_las(
|
|
134
|
+
INPUT_POINTS, INPUT_FILE, OUTPUT_FILE, 68, "EPSG:2154", 1000
|
|
135
|
+
)
|
|
136
|
+
assert Path(OUTPUT_FILE).exists() # check output exists
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
def test_add_points_from_geojson_to_las_no_epsg():
|
|
140
|
+
# Ensure the output file doesn't exist before the test
|
|
141
|
+
if Path(OUTPUT_FILE).exists():
|
|
142
|
+
os.remove(OUTPUT_FILE)
|
|
143
|
+
|
|
144
|
+
INPUT_FILE_WITHOUT_EPSG = os.path.join(TEST_PATH, "data/test_noepsg_043500_629205_IGN69.laz")
|
|
145
|
+
|
|
146
|
+
with pytest.raises(RuntimeError, match="does not have a valid EPSG code"):
|
|
147
|
+
add_points_in_pointcloud.add_points_from_geojson_to_las(
|
|
148
|
+
INPUT_POINTS, INPUT_FILE_WITHOUT_EPSG, OUTPUT_FILE, 68, None, 1000
|
|
149
|
+
)
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
def test_parse_args():
|
|
153
|
+
# sanity check for arguments parsing
|
|
154
|
+
args = add_points_in_pointcloud.parse_args(
|
|
155
|
+
[
|
|
156
|
+
"--input_geojson",
|
|
157
|
+
"data/points_3d/Points_virtuels_0292_6833.geojson",
|
|
158
|
+
"--input_las",
|
|
159
|
+
"data/decimated_laz/test_semis_2023_0292_6833_LA93_IGN69.laz",
|
|
160
|
+
"--output_las",
|
|
161
|
+
"data/output/test_semis_2023_0292_6833_LA93_IGN69.laz",
|
|
162
|
+
"--virtual_points_classes",
|
|
163
|
+
"68",
|
|
164
|
+
"--spatial_ref",
|
|
165
|
+
"EPSG:2154",
|
|
166
|
+
"--tile_width",
|
|
167
|
+
"1000",
|
|
168
|
+
]
|
|
169
|
+
)
|
|
170
|
+
parsed_args_keys = args.__dict__.keys()
|
|
171
|
+
main_parameters = inspect.signature(add_points_in_pointcloud.add_points_from_geojson_to_las).parameters.keys()
|
|
172
|
+
assert set(parsed_args_keys) == set(main_parameters)
|
|
@@ -136,3 +136,17 @@ def test_get_writer_parameters_from_reader_metadata():
|
|
|
136
136
|
out_expected_metadata.pop(key)
|
|
137
137
|
|
|
138
138
|
assert out_metadata == out_expected_metadata
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
def test_get_epsg_from_las_no_epsg():
|
|
142
|
+
input_file = os.path.join(DATA_PATH, "test_noepsg_043500_629205_IGN69.laz")
|
|
143
|
+
|
|
144
|
+
crs = las_info.get_epsg_from_las(input_file)
|
|
145
|
+
assert crs is None
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
def test_get_epsg_from_las_with_epsg():
|
|
149
|
+
input_file = os.path.join(DATA_PATH, "test_data_77050_627755_LA93_IGN69.laz")
|
|
150
|
+
|
|
151
|
+
crs = las_info.get_epsg_from_las(input_file)
|
|
152
|
+
assert crs == "EPSG:2154"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|