ign-pdal-tools 1.15.7__py3-none-any.whl → 1.15.8__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.4
2
2
  Name: ign-pdal-tools
3
- Version: 1.15.7
3
+ Version: 1.15.8
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,5 +1,5 @@
1
- ign_pdal_tools-1.15.7.dist-info/licenses/LICENSE.md,sha256=iVzCFZTUXeiqP8bP474iuWZiWO_kDCD4SPh1Wiw125Y,1120
2
- pdaltools/_version.py,sha256=kSv6LqFM8oHDPBVNwn91sQDq_5bXE71FC-ljZTU7TTA,75
1
+ ign_pdal_tools-1.15.8.dist-info/licenses/LICENSE.md,sha256=iVzCFZTUXeiqP8bP474iuWZiWO_kDCD4SPh1Wiw125Y,1120
2
+ pdaltools/_version.py,sha256=ka-Hq8wFue3GxbOFYtvl29usecZ_BEmqujBzCGJyZ9U,75
3
3
  pdaltools/add_points_in_pointcloud.py,sha256=lDxePBBRTKSEKC3BgrVLWUEMN8vCM4xNgsJfbIz4GRw,12988
4
4
  pdaltools/color.py,sha256=zUNN9BxpajgkisoQ_TC0wBEQqou3gKo8x1KH9EtoRnE,12495
5
5
  pdaltools/create_random_laz.py,sha256=w0P4e3-bzaiKl_osmyFdOcKODRUadU7G4ez9fLvCDrs,6028
@@ -8,7 +8,7 @@ pdaltools/las_add_buffer.py,sha256=WXUkMSRX8T-Xj5il9F_uv7uKSqwUmv5P3AUcHXQVQDE,1
8
8
  pdaltools/las_clip.py,sha256=GvEOYu8RXV68e35kU8i42GwSkbo4P9TvmS6rkrdPmFM,1034
9
9
  pdaltools/las_comparison.py,sha256=ZbWqAjDJ90r3bwzRzMY1nGbpPXMHb52AlQFn1Aoy4jA,7431
10
10
  pdaltools/las_info.py,sha256=xZlTsdLS3I9_xeqGJyOOpJNJrqF82JBhlMhtYabOuw0,9845
11
- pdaltools/las_merge.py,sha256=tcFVueV9X9nNEaoAl5zCduY5DETlBg63MAgP2SuKiNo,4121
11
+ pdaltools/las_merge.py,sha256=MYv4M9WM86Vqb-icPM6hGwdSxY6YuJxhpkR1FDouzsk,5692
12
12
  pdaltools/las_remove_dimensions.py,sha256=f8imGhN6LNTuQ1GMJQRzIIV3Wab_oRPOyEnKi1CgfiM,2318
13
13
  pdaltools/las_rename_dimension.py,sha256=AWYx0Jd5YHWng-CY2yIV8iRTR_bMxhvwGz1MO5sYTWc,2889
14
14
  pdaltools/pcd_info.py,sha256=NIAH5KGikVDQLlbCcw9FuaPqe20UZvRfkHsDZd5kmZA,3210
@@ -16,7 +16,7 @@ pdaltools/replace_area_in_pointcloud.py,sha256=V8aFRSxrqJtsUufoA_5g9ysPl-Wp17_TX
16
16
  pdaltools/replace_attribute_in_las.py,sha256=MHpIizSupgWtbizteoRH8FKDE049hrAh4v_OhmRmSPU,4318
17
17
  pdaltools/standardize_format.py,sha256=-ukrz5gY0mq071fN7EXbB9ANS44IEmgpKQrrjzOnqhE,4455
18
18
  pdaltools/unlock_file.py,sha256=3BplGrcKJ7lpPj1lHTG4ODeuGDXjmeoMeSl3q2Qn2XA,1980
19
- ign_pdal_tools-1.15.7.dist-info/METADATA,sha256=wW1tq6XHysW_bYfWg9VXY7xo7vyHQygSrj4qyw9aSwU,6146
20
- ign_pdal_tools-1.15.7.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
21
- ign_pdal_tools-1.15.7.dist-info/top_level.txt,sha256=KvGW0ZzqQbhCKzB5_Tp_buWMZyIgiO2M2krWF_ecOZc,10
22
- ign_pdal_tools-1.15.7.dist-info/RECORD,,
19
+ ign_pdal_tools-1.15.8.dist-info/METADATA,sha256=YtXPvSSqPe7WRsckKRF4hbCPaCH8TEagbz8QnMi1T8Y,6146
20
+ ign_pdal_tools-1.15.8.dist-info/WHEEL,sha256=qELbo2s1Yzl39ZmrAibXA2jjPLUYfnVhUNTlyF1rq0Y,92
21
+ ign_pdal_tools-1.15.8.dist-info/top_level.txt,sha256=KvGW0ZzqQbhCKzB5_Tp_buWMZyIgiO2M2krWF_ecOZc,10
22
+ ign_pdal_tools-1.15.8.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.9.0)
2
+ Generator: setuptools (80.10.1)
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.15.7"
1
+ __version__ = "1.15.8"
2
2
 
3
3
 
4
4
  if __name__ == "__main__":
pdaltools/las_merge.py CHANGED
@@ -6,20 +6,25 @@ import pdal
6
6
  from pdaltools.las_info import parse_filename
7
7
 
8
8
 
9
- def create_filenames(file: str, tile_width: int = 1000, tile_coord_scale: int = 1000):
9
+ def create_filenames_suffixes(file: str, tile_width: int = 1000, tile_coord_scale: int = 1000):
10
10
  """Generate the name of the tiles around the input LIDAR tile
11
11
  It supposes that the file names are formatted as {prefix1}_{prefix2}_{coordx}_{coordy}_{suffix}
12
12
  with coordx and coordy having at least 4 digits
13
13
 
14
14
  For example Semis_2021_0000_1111_LA93_IGN69.las
15
15
 
16
+ Generates only the suffix part of the filename, for example, for file like above, it will generate:
17
+ _0000_1112_LA93_IGN69.las
18
+ _0001_1112_LA93_IGN69.las
19
+ ...
20
+
16
21
  Args:
17
22
  file(str): name of LIDAR file
18
23
  tile width (int): width of tiles in meters (usually 1000m)
19
24
  tile_coord_scale (int) : scale used in the filename to describe coordinates in meters
20
25
  (usually 1000m)
21
26
  Returns:
22
- list_input(list): List of LIDAR's name
27
+ list_input(list): List of LIDAR's filename suffix.
23
28
  """
24
29
 
25
30
  # Create name of LIDAR tiles who cercle the tile
@@ -27,42 +32,52 @@ def create_filenames(file: str, tile_width: int = 1000, tile_coord_scale: int =
27
32
  _prefix, coord_x, coord_y, _suffix = parse_filename(file)
28
33
  offset = int(tile_width / tile_coord_scale)
29
34
  # On left
30
- _tile_hl = f"{_prefix}_{(coord_x - offset):04d}_{(coord_y + offset):04d}_{_suffix}"
31
- _tile_ml = f"{_prefix}_{(coord_x - offset):04d}_{coord_y:04d}_{_suffix}"
32
- _tile_bl = f"{_prefix}_{(coord_x - offset):04d}_{(coord_y - offset):04d}_{_suffix}"
35
+ _tile_hl = f"_{(coord_x - offset):04d}_{(coord_y + offset):04d}_{_suffix}"
36
+ _tile_ml = f"_{(coord_x - offset):04d}_{coord_y:04d}_{_suffix}"
37
+ _tile_bl = f"_{(coord_x - offset):04d}_{(coord_y - offset):04d}_{_suffix}"
33
38
  # On Right
34
- _tile_hr = f"{_prefix}_{(coord_x + offset):04d}_{(coord_y + offset):04d}_{_suffix}"
35
- _tile_mr = f"{_prefix}_{(coord_x + offset):04d}_{coord_y:04d}_{_suffix}"
36
- _tile_br = f"{_prefix}_{(coord_x + offset):04d}_{(coord_y - offset):04d}_{_suffix}"
39
+ _tile_hr = f"_{(coord_x + offset):04d}_{(coord_y + offset):04d}_{_suffix}"
40
+ _tile_mr = f"_{(coord_x + offset):04d}_{coord_y:04d}_{_suffix}"
41
+ _tile_br = f"_{(coord_x + offset):04d}_{(coord_y - offset):04d}_{_suffix}"
37
42
  # Above
38
- _tile_a = f"{_prefix}_{coord_x:04d}_{(coord_y + offset):04d}_{_suffix}"
43
+ _tile_a = f"_{coord_x:04d}_{(coord_y + offset):04d}_{_suffix}"
39
44
  # Below
40
- _tile_b = f"{_prefix}_{coord_x:04d}_{(coord_y - offset):04d}_{_suffix}"
45
+ _tile_b = f"_{coord_x:04d}_{(coord_y - offset):04d}_{_suffix}"
41
46
  # Return the severals tile's names
42
47
  return _tile_hl, _tile_ml, _tile_bl, _tile_a, _tile_b, _tile_hr, _tile_mr, _tile_br
43
48
 
44
49
 
45
- def check_tiles_exist(list_las: list):
46
- """Check if pointclouds exist
50
+ def match_suffix_with_filenames(suffix_list: list, all_files: list, las_dir: str):
51
+ """Match suffix list with real filenames
47
52
  Args:
48
- list_las (list): Filenames of the tiles around the LIDAR tile
53
+ suffix_list (list): List of suffix patterns to match
54
+ all_files (list): List of all files in las_dir
55
+ las_dir (str): Directory of pointclouds
49
56
 
50
57
  Returns:
51
- li(List): Pruned list of filenames with only existing files
58
+ las_list(List): List of matched files
52
59
  """
53
- li = []
54
- for i in list_las:
55
- if not os.path.exists(i):
56
- logging.info(f"NOK : {i}")
57
- pass
60
+ las_list = []
61
+ for suffix in suffix_list:
62
+ matches = [filename for filename in all_files if filename.endswith(suffix)]
63
+ if len(matches) == 0:
64
+ logging.info(f"NOK : {suffix}")
58
65
  else:
59
- li.append(i)
60
- return li
66
+ # in case of multiple matches, select the most recent year (ex: Semis_2021_ before Semis_2020_ )
67
+ matches.sort(reverse=True)
68
+ selected = matches[0]
69
+ if len(matches) > 1:
70
+ logging.warning(f"Multiple matches for {suffix} : {matches} ; taking {selected}")
61
71
 
72
+ # Append full path
73
+ las_list.append(os.path.join(las_dir, selected))
74
+ return las_list
62
75
 
63
- def create_list(las_dir, input_file, tile_width=1000, tile_coord_scale=1000):
76
+
77
+ def create_tiles_list(all_files, las_dir, input_file, tile_width=1000, tile_coord_scale=1000):
64
78
  """Return the paths of 8 tiles around the tile + the input tile
65
79
  Args:
80
+ all_files (list): list of all files in las_dir
66
81
  las_dir (str): directory of pointclouds
67
82
  input_file (str): path to queried LIDAR tile
68
83
  tile_width (int): Width of a tile(in the reference unit: 1m)
@@ -70,19 +85,39 @@ def create_list(las_dir, input_file, tile_width=1000, tile_coord_scale=1000):
70
85
  1000 * 1m (with 1m being the reference)
71
86
 
72
87
  Returns:
73
- list_files(li): list of tiles
88
+ list_files: list of tiles
74
89
  """
75
90
 
76
- # Return list 8 tiles around the tile
77
- list_input = create_filenames(os.path.basename(input_file), tile_width, tile_coord_scale)
78
- # List pointclouds
79
- li = [os.path.join(las_dir, e) for e in list_input]
80
- # Keep only existing files
81
- li = check_tiles_exist(li)
91
+ # Return list 8 tiles around the tile, but only the suffix part of the name.
92
+ suffix_list = create_filenames_suffixes(os.path.basename(input_file), tile_width, tile_coord_scale)
93
+
94
+ # Match suffix patterns with real files
95
+ list_files = match_suffix_with_filenames(suffix_list, all_files, las_dir)
96
+
82
97
  # Appending queried tile to list
83
- li.append(input_file)
98
+ list_files.append(input_file)
99
+
100
+ return list_files
101
+
102
+
103
+ def create_list(las_dir, input_file, tile_width=1000, tile_coord_scale=1000):
104
+ """Return the paths of 8 tiles around the tile + the input tile
105
+ Args:
106
+ las_dir (str): directory of pointclouds
107
+ input_file (str): path to queried LIDAR tile
108
+ tile_width (int): Width of a tile(in the reference unit: 1m)
109
+ tile_coord_scale (int): Scale used in filename to describe coordinates (usually kilometers)
110
+ 1000 * 1m (with 1m being the reference)
111
+
112
+ Returns:
113
+ list_files: list of tiles
114
+ """
115
+
116
+ # list files on the disk
117
+ all_files = os.listdir(las_dir)
84
118
 
85
- return li
119
+ # call the function with the list of files
120
+ return create_tiles_list(all_files, las_dir, input_file, tile_width, tile_coord_scale)
86
121
 
87
122
 
88
123
  def las_merge(las_dir, input_file, merge_file, tile_width=1000, tile_coord_scale=1000):