ign-pdal-tools 1.7.3__py3-none-any.whl → 1.7.4__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.1
2
2
  Name: ign-pdal-tools
3
- Version: 1.7.3
3
+ Version: 1.7.4
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
@@ -0,0 +1,16 @@
1
+ pdaltools/_version.py,sha256=lNYVqr3yBgm8bym5YoCi_BcGRCVp-3qRpo5R-aiwjwQ,74
2
+ pdaltools/color.py,sha256=PSdtMMdsapOtgzojdnaKVx6IxbKOaN2xP9mScAbCGm0,8629
3
+ pdaltools/las_add_buffer.py,sha256=sBpTywlfsHHS8KuCUa-eydB2hylshEvjrMQt5TrqXb8,11275
4
+ pdaltools/las_clip.py,sha256=GvEOYu8RXV68e35kU8i42GwSkbo4P9TvmS6rkrdPmFM,1034
5
+ pdaltools/las_info.py,sha256=RE-UBdEUXqKvSrMV3mOlvE_16mhum7bw-p-ERu5bGOc,6979
6
+ pdaltools/las_merge.py,sha256=tcFVueV9X9nNEaoAl5zCduY5DETlBg63MAgP2SuKiNo,4121
7
+ pdaltools/las_remove_dimensions.py,sha256=J9-jBvT3APKUuPwuqAv_Sf5aW8lHxnpnFKZcxiC_Kno,1802
8
+ pdaltools/pcd_info.py,sha256=d7ukCEdOFBQqaFp3HYM2MNbKDl1hdxUVHI9vSu9jN-M,1897
9
+ pdaltools/replace_attribute_in_las.py,sha256=po1F-fi8s7iilqKWaryW4JRbsmdMOUe0yGvG3AEKxtk,4771
10
+ pdaltools/standardize_format.py,sha256=xx3FHU8rqV-uLQgWGJtThn5G5hfCxkKag6fXGH4JOXs,3981
11
+ pdaltools/unlock_file.py,sha256=pIThdWMNkTph0xgJVVRaM1o9aUMQhM6804PscScB3JI,1963
12
+ ign_pdal_tools-1.7.4.dist-info/LICENSE.md,sha256=iVzCFZTUXeiqP8bP474iuWZiWO_kDCD4SPh1Wiw125Y,1120
13
+ ign_pdal_tools-1.7.4.dist-info/METADATA,sha256=_naab5v10YXIqMh9bF7cUgKCUbJlfF5r4w6gOjKNc5s,5112
14
+ ign_pdal_tools-1.7.4.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
15
+ ign_pdal_tools-1.7.4.dist-info/top_level.txt,sha256=KvGW0ZzqQbhCKzB5_Tp_buWMZyIgiO2M2krWF_ecOZc,10
16
+ ign_pdal_tools-1.7.4.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (74.0.0)
2
+ Generator: setuptools (75.1.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.3"
1
+ __version__ = "1.7.4"
2
2
 
3
3
 
4
4
  if __name__ == "__main__":
pdaltools/color.py CHANGED
@@ -69,11 +69,11 @@ def is_image_white(filename: str):
69
69
  def download_image_from_geoplateforme(
70
70
  proj, layer, minx, miny, maxx, maxy, pixel_per_meter, outfile, timeout, check_images
71
71
  ):
72
- # Give single-point clouds a width/height of at least one pixel to have valid BBOX and SIZE
73
- if minx == maxx:
74
- maxx = minx + 1 / pixel_per_meter
75
- if miny == maxy:
76
- maxy = miny + 1 / pixel_per_meter
72
+ # Force a 1-pixel margin in the east and south borders
73
+ # to make sure that no point of the pointcloud is on the limit of the last pixel
74
+ # to prevent interpolation issues
75
+ maxx = maxx + 1 / pixel_per_meter
76
+ miny = miny - 1 / pixel_per_meter
77
77
 
78
78
  # for layer in layers:
79
79
  URL_GPP = "https://data.geopf.fr/wms-r/wms?"
@@ -136,22 +136,26 @@ def color(
136
136
 
137
137
  tmp_ortho = None
138
138
  if color_rvb_enabled:
139
- tmp_ortho = tempfile.NamedTemporaryFile()
139
+ tmp_ortho = tempfile.NamedTemporaryFile(suffix="_rvb.tif")
140
140
  download_image_from_geoplateforme_retrying(
141
141
  proj, stream_RGB, minx, miny, maxx, maxy, pixel_per_meter, tmp_ortho.name, timeout_second, check_images
142
142
  )
143
-
143
+ # Warning: the initial color is multiplied by 256 despite its initial 8-bits encoding
144
+ # which turns it to a 0 to 255*256 range.
145
+ # It is kept this way because of other dependencies that have been tuned to fit this range
144
146
  pipeline |= pdal.Filter.colorization(
145
147
  raster=tmp_ortho.name, dimensions="Red:1:256.0, Green:2:256.0, Blue:3:256.0"
146
148
  )
147
149
 
148
150
  tmp_ortho_irc = None
149
151
  if color_ir_enabled:
150
- tmp_ortho_irc = tempfile.NamedTemporaryFile()
152
+ tmp_ortho_irc = tempfile.NamedTemporaryFile(suffix="_irc.tif")
151
153
  download_image_from_geoplateforme_retrying(
152
154
  proj, stream_IRC, minx, miny, maxx, maxy, pixel_per_meter, tmp_ortho_irc.name, timeout_second, check_images
153
155
  )
154
-
156
+ # Warning: the initial color is multiplied by 256 despite its initial 8-bits encoding
157
+ # which turns it to a 0 to 255*256 range.
158
+ # It is kept this way because of other dependencies that have been tuned to fit this range
155
159
  pipeline |= pdal.Filter.colorization(raster=tmp_ortho_irc.name, dimensions="Infrared:1:256.0")
156
160
 
157
161
  pipeline |= pdal.Writer.las(
@@ -4,6 +4,7 @@ import os
4
4
  import pdal
5
5
  from pdaltools.las_info import get_writer_parameters_from_reader_metadata
6
6
 
7
+
7
8
  def remove_dimensions_from_las(input_las: str, dimensions: [str], output_las: str):
8
9
  """
9
10
  export new las without some dimensions
@@ -43,7 +44,7 @@ def parse_args():
43
44
  required=True,
44
45
  nargs="+",
45
46
  help="The dimension we would like to remove from the point cloud file ; be aware to not remove mandatory "
46
- "dimensions of las"
47
+ "dimensions of las",
47
48
  )
48
49
 
49
50
  return parser.parse_args()
@@ -10,9 +10,10 @@
10
10
 
11
11
  import argparse
12
12
  import os
13
+ import platform
13
14
  import subprocess as sp
14
15
  import tempfile
15
- from typing import Dict
16
+ from typing import Dict, List
16
17
 
17
18
  import pdal
18
19
 
@@ -32,6 +33,7 @@ STANDARD_PARAMETERS = dict(
32
33
  offset_z=0,
33
34
  dataformat_id=6, # No color by default
34
35
  a_srs="EPSG:2154",
36
+ class_points_removed=[], # remove points from class
35
37
  )
36
38
 
37
39
 
@@ -43,6 +45,13 @@ def parse_args():
43
45
  "--record_format", choices=[6, 8], type=int, help="Record format: 6 (no color) or 8 (4 color channels)"
44
46
  )
45
47
  parser.add_argument("--projection", default="EPSG:2154", type=str, help="Projection, eg. EPSG:2154")
48
+ parser.add_argument(
49
+ "--class_points_removed",
50
+ default=[],
51
+ nargs="*",
52
+ type=str,
53
+ help="List of classes number. Points of this classes will be removed from the file",
54
+ )
46
55
  parser.add_argument(
47
56
  "--extra_dims",
48
57
  default=[],
@@ -51,7 +60,6 @@ def parse_args():
51
60
  help="List of extra dims to keep in the output (default=[], use 'all' to keep all extra dims), "
52
61
  "extra_dims must be specified with their type (see pdal.writers.las documentation, eg 'dim1=double')",
53
62
  )
54
-
55
63
  return parser.parse_args()
56
64
 
57
65
 
@@ -61,20 +69,28 @@ def get_writer_parameters(new_parameters: Dict) -> Dict:
61
69
  override the standard ones
62
70
  """
63
71
  params = STANDARD_PARAMETERS | new_parameters
64
-
65
72
  return params
66
73
 
67
74
 
68
- def rewrite_with_pdal(input_file: str, output_file: str, params_from_parser: Dict) -> None:
69
- # Update parameters with command line values
75
+ def rewrite_with_pdal(
76
+ input_file: str, output_file: str, params_from_parser: Dict, classes_to_remove: List = []
77
+ ) -> None:
70
78
  params = get_writer_parameters(params_from_parser)
71
- pipeline = pdal.Reader.las(input_file)
79
+ pipeline = pdal.Pipeline()
80
+ pipeline |= pdal.Reader.las(input_file)
81
+ if classes_to_remove:
82
+ expression = "&&".join([f"Classification != {c}" for c in classes_to_remove])
83
+ pipeline |= pdal.Filter.expression(expression=expression)
72
84
  pipeline |= pdal.Writer(filename=output_file, forward="all", **params)
73
85
  pipeline.execute()
74
86
 
75
87
 
76
88
  def exec_las2las(input_file: str, output_file: str):
77
- r = sp.run(["las2las", "-i", input_file, "-o", output_file], stderr=sp.PIPE, stdout=sp.PIPE)
89
+ if platform.processor() == "arm" and platform.architecture()[0] == "64bit":
90
+ las2las = "las2las64"
91
+ else:
92
+ las2las = "las2las"
93
+ r = sp.run([las2las, "-i", input_file, "-o", output_file], stderr=sp.PIPE, stdout=sp.PIPE)
78
94
  if r.returncode == 1:
79
95
  msg = r.stderr.decode()
80
96
  print(msg)
@@ -86,14 +102,18 @@ def exec_las2las(input_file: str, output_file: str):
86
102
 
87
103
 
88
104
  @copy_and_hack_decorator
89
- def standardize(input_file: str, output_file: str, params_from_parser: Dict) -> None:
105
+ def standardize(input_file: str, output_file: str, params_from_parser: Dict, class_points_removed: []) -> None:
90
106
  filename = os.path.basename(output_file)
91
107
  with tempfile.NamedTemporaryFile(suffix=filename) as tmp:
92
- rewrite_with_pdal(input_file, tmp.name, params_from_parser)
108
+ rewrite_with_pdal(input_file, tmp.name, params_from_parser, class_points_removed)
93
109
  exec_las2las(tmp.name, output_file)
94
110
 
95
111
 
96
112
  if __name__ == "__main__":
97
113
  args = parse_args()
98
- params_from_parser = dict(dataformat_id=args.record_format, a_srs=args.projection, extra_dims=args.extra_dims)
99
- standardize(args.input_file, args.output_file, params_from_parser)
114
+ params_from_parser = dict(
115
+ dataformat_id=args.record_format,
116
+ a_srs=args.projection,
117
+ extra_dims=args.extra_dims,
118
+ )
119
+ standardize(args.input_file, args.output_file, params_from_parser, args.class_points_removed)
@@ -1,16 +0,0 @@
1
- pdaltools/_version.py,sha256=CIj6_M9SXht6CUH70oDuQQl4_AP2fggn-8tFZbGL0AY,74
2
- pdaltools/color.py,sha256=7U-SThIKqrfE1xXXnFqpbIhmZEqna29nRiyLW8l8Y1c,8075
3
- pdaltools/las_add_buffer.py,sha256=sBpTywlfsHHS8KuCUa-eydB2hylshEvjrMQt5TrqXb8,11275
4
- pdaltools/las_clip.py,sha256=GvEOYu8RXV68e35kU8i42GwSkbo4P9TvmS6rkrdPmFM,1034
5
- pdaltools/las_info.py,sha256=RE-UBdEUXqKvSrMV3mOlvE_16mhum7bw-p-ERu5bGOc,6979
6
- pdaltools/las_merge.py,sha256=tcFVueV9X9nNEaoAl5zCduY5DETlBg63MAgP2SuKiNo,4121
7
- pdaltools/las_remove_dimensions.py,sha256=0zhv9LBvlL69TLmXTJlRQcUBOaBmCRZEQU2Qadx27aM,1805
8
- pdaltools/pcd_info.py,sha256=d7ukCEdOFBQqaFp3HYM2MNbKDl1hdxUVHI9vSu9jN-M,1897
9
- pdaltools/replace_attribute_in_las.py,sha256=po1F-fi8s7iilqKWaryW4JRbsmdMOUe0yGvG3AEKxtk,4771
10
- pdaltools/standardize_format.py,sha256=lUzrjWY22WfxT_2zLtxuXbmWgiAvjy9o7fBXWsAZmDg,3240
11
- pdaltools/unlock_file.py,sha256=pIThdWMNkTph0xgJVVRaM1o9aUMQhM6804PscScB3JI,1963
12
- ign_pdal_tools-1.7.3.dist-info/LICENSE.md,sha256=iVzCFZTUXeiqP8bP474iuWZiWO_kDCD4SPh1Wiw125Y,1120
13
- ign_pdal_tools-1.7.3.dist-info/METADATA,sha256=PfhYtt73bGGZxehInuRGdzwfhfW_1UxMO7K3CrPlDL0,5112
14
- ign_pdal_tools-1.7.3.dist-info/WHEEL,sha256=UvcQYKBHoFqaQd6LKyqHw9fxEolWLQnlzP0h_LgJAfI,91
15
- ign_pdal_tools-1.7.3.dist-info/top_level.txt,sha256=KvGW0ZzqQbhCKzB5_Tp_buWMZyIgiO2M2krWF_ecOZc,10
16
- ign_pdal_tools-1.7.3.dist-info/RECORD,,