ign-pdal-tools 1.7.7__py3-none-any.whl → 1.7.9__py3-none-any.whl

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: ign-pdal-tools
3
- Version: 1.7.7
3
+ Version: 1.7.9
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,18 +1,18 @@
1
- pdaltools/_version.py,sha256=k34KtTIEeE3AZ8JK-MhAdByywWh56CG4yUanH4EBsFM,74
1
+ pdaltools/_version.py,sha256=2YxDctk7vFYaW4gZ_YqrDboXUkA5pH4qHhNoYN-p2xc,74
2
2
  pdaltools/add_points_in_las.py,sha256=TGbt5JUkszjmbQiA2LCUntsjz6A8DHb7QPIXGDuEgWA,3643
3
- pdaltools/add_points_in_pointcloud.py,sha256=ldHQFsV0zpZiG38lJrxhAfsckTwkK4g0BkmXyzHmzmE,6186
4
- pdaltools/color.py,sha256=PSdtMMdsapOtgzojdnaKVx6IxbKOaN2xP9mScAbCGm0,8629
3
+ pdaltools/add_points_in_pointcloud.py,sha256=g9V_gUA-vOy3wuYdWXFSObDZtSKO2LhzXa5Vy-yypuA,5684
4
+ pdaltools/color.py,sha256=-a0ramyLMkZX4-M3siPq1zIio5u-a0p8UzvgcfoU6zU,8313
5
5
  pdaltools/las_add_buffer.py,sha256=sBpTywlfsHHS8KuCUa-eydB2hylshEvjrMQt5TrqXb8,11275
6
6
  pdaltools/las_clip.py,sha256=GvEOYu8RXV68e35kU8i42GwSkbo4P9TvmS6rkrdPmFM,1034
7
- pdaltools/las_info.py,sha256=rHweSNFOV1fD8XKVbfAv4bkUWwhr5SGzX9Kr-qCORlk,8682
7
+ pdaltools/las_info.py,sha256=lMKxKzsViptDENI1wOlANG4qOvdc19ixyasYKD-N1ck,9512
8
8
  pdaltools/las_merge.py,sha256=tcFVueV9X9nNEaoAl5zCduY5DETlBg63MAgP2SuKiNo,4121
9
9
  pdaltools/las_remove_dimensions.py,sha256=u_3VfkabkN_Y3eDLdJwCLVGpondvIx0f0v0RdFDoAFw,1792
10
10
  pdaltools/pcd_info.py,sha256=NIAH5KGikVDQLlbCcw9FuaPqe20UZvRfkHsDZd5kmZA,3210
11
11
  pdaltools/replace_attribute_in_las.py,sha256=po1F-fi8s7iilqKWaryW4JRbsmdMOUe0yGvG3AEKxtk,4771
12
12
  pdaltools/standardize_format.py,sha256=gqm2GJbtDkT4k4oC_NX2LIPh9R2BLh4sMHLKYgfKrMc,3973
13
13
  pdaltools/unlock_file.py,sha256=pIThdWMNkTph0xgJVVRaM1o9aUMQhM6804PscScB3JI,1963
14
- ign_pdal_tools-1.7.7.dist-info/LICENSE.md,sha256=iVzCFZTUXeiqP8bP474iuWZiWO_kDCD4SPh1Wiw125Y,1120
15
- ign_pdal_tools-1.7.7.dist-info/METADATA,sha256=8yQ2NV4g9oakIZfylyAvmBkV8qzNsPL_-vA2CUcG5Cs,5722
16
- ign_pdal_tools-1.7.7.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
17
- ign_pdal_tools-1.7.7.dist-info/top_level.txt,sha256=KvGW0ZzqQbhCKzB5_Tp_buWMZyIgiO2M2krWF_ecOZc,10
18
- ign_pdal_tools-1.7.7.dist-info/RECORD,,
14
+ ign_pdal_tools-1.7.9.dist-info/LICENSE.md,sha256=iVzCFZTUXeiqP8bP474iuWZiWO_kDCD4SPh1Wiw125Y,1120
15
+ ign_pdal_tools-1.7.9.dist-info/METADATA,sha256=hVkIMUlnlbfnsMplmEmwC4sSKdWXS6X1K85XJUhqrkc,5722
16
+ ign_pdal_tools-1.7.9.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
17
+ ign_pdal_tools-1.7.9.dist-info/top_level.txt,sha256=KvGW0ZzqQbhCKzB5_Tp_buWMZyIgiO2M2krWF_ecOZc,10
18
+ ign_pdal_tools-1.7.9.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.8.0)
2
+ Generator: setuptools (76.0.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
pdaltools/_version.py CHANGED
@@ -1,4 +1,4 @@
1
- __version__ = "1.7.7"
1
+ __version__ = "1.7.9"
2
2
 
3
3
 
4
4
  if __name__ == "__main__":
@@ -1,4 +1,5 @@
1
1
  import argparse
2
+ import shutil
2
3
 
3
4
  import geopandas as gpd
4
5
  import laspy
@@ -7,7 +8,7 @@ from pyproj import CRS
7
8
  from pyproj.exceptions import CRSError
8
9
  from shapely.geometry import box
9
10
 
10
- from pdaltools.las_info import get_epsg_from_las, get_tile_origin_using_header_info
11
+ from pdaltools.las_info import get_epsg_from_las, get_tile_bbox
11
12
 
12
13
 
13
14
  def parse_args(argv=None):
@@ -38,23 +39,6 @@ def parse_args(argv=None):
38
39
  return parser.parse_args(argv)
39
40
 
40
41
 
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
42
  def clip_3d_points_to_tile(input_points: str, input_las: str, crs: str, tile_width: int) -> gpd.GeoDataFrame:
59
43
  """
60
44
  Add points from a GeoJSON file in the LIDAR's tile.
@@ -98,9 +82,14 @@ def add_points_to_las(
98
82
  crs (str): CRS of the data.
99
83
  virtual_points_classes (int): The classification value to assign to those virtual points (default: 66).
100
84
  """
101
- # Check if input points are empty
85
+
102
86
  if input_points_with_z.empty:
103
- raise ValueError("No points to add. The input GeoDataFrame is empty.")
87
+ print(
88
+ "No points to add. All points of the geojson file are outside the tile. Copying the input file to output"
89
+ )
90
+ shutil.copy(input_las, output_las)
91
+
92
+ return
104
93
 
105
94
  # Extract XYZ coordinates and additional attribute (classification)
106
95
  x_coords = input_points_with_z.geometry.x
pdaltools/color.py CHANGED
@@ -37,15 +37,9 @@ def retry(times, delay, factor=2, debug=False):
37
37
  need_retry = False
38
38
  try:
39
39
  return func(*args, **kwargs)
40
- except requests.exceptions.ConnectionError as err:
40
+ except requests.exceptions.RequestException as err:
41
41
  print("Connection Error:", err)
42
42
  need_retry = True
43
- except requests.exceptions.HTTPError as err:
44
- if "Server Error" in str(err):
45
- print("HTTP Error:", err)
46
- need_retry = True
47
- else:
48
- raise err
49
43
  if need_retry:
50
44
  print(f"{attempt}/{times} Nouvel essai après une pause de {pretty_time_delta(new_delay)} .. ")
51
45
  if not debug:
@@ -126,8 +120,7 @@ def color(
126
120
 
127
121
  writer_extra_dims = "all"
128
122
 
129
- # apply decorator to retry 3 times, and wait 30 seconds each times
130
- download_image_from_geoplateforme_retrying = retry(7, 15, 2)(download_image_from_geoplateforme)
123
+ download_image_from_geoplateforme_retrying = retry(times=9, delay=5, factor=2)(download_image_from_geoplateforme)
131
124
 
132
125
  if veget_index_file and veget_index_file != "":
133
126
  print(f"Remplissage du champ Deviation à partir du fichier {veget_index_file}")
pdaltools/las_info.py CHANGED
@@ -1,6 +1,7 @@
1
1
  import json
2
2
  import logging
3
3
  import os
4
+ from pathlib import Path
4
5
  from typing import Dict, Tuple
5
6
 
6
7
  import laspy
@@ -51,6 +52,23 @@ def get_tile_origin_using_header_info(filename: str, tile_width: int = 1000) ->
51
52
  return infer_tile_origin(minx, maxx, miny, maxy, tile_width)
52
53
 
53
54
 
55
+ def get_tile_bbox(input_las, tile_width=1000) -> tuple:
56
+ """
57
+ Get the theoretical bounding box (xmin, ymin, xmax, ymax) of a LIDAR tile
58
+ using its origin and the predefined tile width.
59
+
60
+ Args:
61
+ input_las (str): Path to the LIDAR `.las/.laz` file.
62
+ tile_width (int): Width of the tile in meters (default: 1000).
63
+
64
+ Returns:
65
+ tuple: Bounding box as (xmin, ymin, xmax, ymax).
66
+ """
67
+ origin_x, origin_y = get_tile_origin_using_header_info(input_las, tile_width)
68
+ bbox = (origin_x, origin_y - tile_width, origin_x + tile_width, origin_y)
69
+ return bbox
70
+
71
+
54
72
  def get_epsg_from_header_info(metadata):
55
73
  if "srs" not in metadata.keys():
56
74
  raise RuntimeError("EPSG could not be inferred from metadata: No 'srs' key in metadata.")
@@ -143,7 +161,14 @@ def parse_filename(file: str):
143
161
  For example Semis_2021_0000_1111_LA93_IGN69.las"""
144
162
  basename = os.path.basename(file) # Make sure that we work on the base name and not the full path
145
163
 
146
- prefix1, prefix2, coordx, coordy, suffix = basename.split("_", 4)
164
+ try:
165
+ prefix1, prefix2, coordx, coordy, suffix = basename.split("_", 4)
166
+ except ValueError:
167
+ raise ValueError(
168
+ f"Filename {Path(file).name} does not have the expected format. "
169
+ "Expected prefix1_prefix2_coordx_coordy_suffix"
170
+ )
171
+
147
172
  prefix = f"{prefix1}_{prefix2}"
148
173
 
149
174
  return prefix, int(coordx), int(coordy), suffix