ign-pdal-tools 1.5.2__py3-none-any.whl → 1.6.0__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.
- {ign_pdal_tools-1.5.2.dist-info → ign_pdal_tools-1.6.0.dist-info}/METADATA +1 -1
- {ign_pdal_tools-1.5.2.dist-info → ign_pdal_tools-1.6.0.dist-info}/RECORD +7 -7
- {ign_pdal_tools-1.5.2.dist-info → ign_pdal_tools-1.6.0.dist-info}/WHEEL +1 -1
- pdaltools/_version.py +1 -1
- pdaltools/color.py +53 -13
- {ign_pdal_tools-1.5.2.dist-info → ign_pdal_tools-1.6.0.dist-info}/LICENSE.md +0 -0
- {ign_pdal_tools-1.5.2.dist-info → ign_pdal_tools-1.6.0.dist-info}/top_level.txt +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
pdaltools/_version.py,sha256=
|
|
2
|
-
pdaltools/color.py,sha256=
|
|
1
|
+
pdaltools/_version.py,sha256=Xq8G0zFAUQ7LL7Y4z3YbruoLpmF2hoaWnL6BPpSAP6M,74
|
|
2
|
+
pdaltools/color.py,sha256=7U-SThIKqrfE1xXXnFqpbIhmZEqna29nRiyLW8l8Y1c,8075
|
|
3
3
|
pdaltools/las_add_buffer.py,sha256=_syALdaf6ks5KSINlfkALwGUrPOHLhK8rGlYVwDamzc,5653
|
|
4
4
|
pdaltools/las_clip.py,sha256=GvEOYu8RXV68e35kU8i42GwSkbo4P9TvmS6rkrdPmFM,1034
|
|
5
5
|
pdaltools/las_info.py,sha256=RE-UBdEUXqKvSrMV3mOlvE_16mhum7bw-p-ERu5bGOc,6979
|
|
@@ -7,8 +7,8 @@ pdaltools/las_merge.py,sha256=tcFVueV9X9nNEaoAl5zCduY5DETlBg63MAgP2SuKiNo,4121
|
|
|
7
7
|
pdaltools/replace_attribute_in_las.py,sha256=po1F-fi8s7iilqKWaryW4JRbsmdMOUe0yGvG3AEKxtk,4771
|
|
8
8
|
pdaltools/standardize_format.py,sha256=KM_jC_aC9yLD5rrSUGgTwfyakbh86FXsAI-y8gokF4M,2883
|
|
9
9
|
pdaltools/unlock_file.py,sha256=pIThdWMNkTph0xgJVVRaM1o9aUMQhM6804PscScB3JI,1963
|
|
10
|
-
ign_pdal_tools-1.
|
|
11
|
-
ign_pdal_tools-1.
|
|
12
|
-
ign_pdal_tools-1.
|
|
13
|
-
ign_pdal_tools-1.
|
|
14
|
-
ign_pdal_tools-1.
|
|
10
|
+
ign_pdal_tools-1.6.0.dist-info/LICENSE.md,sha256=iVzCFZTUXeiqP8bP474iuWZiWO_kDCD4SPh1Wiw125Y,1120
|
|
11
|
+
ign_pdal_tools-1.6.0.dist-info/METADATA,sha256=3BZwbcQ_mDIr1XzK5JZMrjIQmRcN__FW62GMp9FKrIQ,4825
|
|
12
|
+
ign_pdal_tools-1.6.0.dist-info/WHEEL,sha256=cpQTJ5IWu9CdaPViMhC9YzF8gZuS5-vlfoFihTBC86A,91
|
|
13
|
+
ign_pdal_tools-1.6.0.dist-info/top_level.txt,sha256=KvGW0ZzqQbhCKzB5_Tp_buWMZyIgiO2M2krWF_ecOZc,10
|
|
14
|
+
ign_pdal_tools-1.6.0.dist-info/RECORD,,
|
pdaltools/_version.py
CHANGED
pdaltools/color.py
CHANGED
|
@@ -3,8 +3,10 @@ import tempfile
|
|
|
3
3
|
import time
|
|
4
4
|
from math import ceil
|
|
5
5
|
|
|
6
|
+
import numpy as np
|
|
6
7
|
import pdal
|
|
7
8
|
import requests
|
|
9
|
+
from osgeo import gdal_array
|
|
8
10
|
|
|
9
11
|
import pdaltools.las_info as las_info
|
|
10
12
|
from pdaltools.unlock_file import copy_and_hack_decorator
|
|
@@ -58,7 +60,15 @@ def retry(times, delay, factor=2, debug=False):
|
|
|
58
60
|
return decorator
|
|
59
61
|
|
|
60
62
|
|
|
61
|
-
def
|
|
63
|
+
def is_image_white(filename: str):
|
|
64
|
+
raster_array = gdal_array.LoadFile(filename)
|
|
65
|
+
band_is_white = [np.all(band == 255) for band in raster_array]
|
|
66
|
+
return np.all(band_is_white)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def download_image_from_geoplateforme(
|
|
70
|
+
proj, layer, minx, miny, maxx, maxy, pixel_per_meter, outfile, timeout, check_images
|
|
71
|
+
):
|
|
62
72
|
# Give single-point clouds a width/height of at least one pixel to have valid BBOX and SIZE
|
|
63
73
|
if minx == maxx:
|
|
64
74
|
maxx = minx + 1 / pixel_per_meter
|
|
@@ -88,6 +98,9 @@ def download_image_from_geoplateforme(proj, layer, minx, miny, maxx, maxy, pixel
|
|
|
88
98
|
print(f"Ecriture du fichier: {outfile}")
|
|
89
99
|
open(outfile, "wb").write(req.content)
|
|
90
100
|
|
|
101
|
+
if check_images and is_image_white(outfile):
|
|
102
|
+
raise ValueError(f"Downloaded image is white, with stream: {layer}")
|
|
103
|
+
|
|
91
104
|
|
|
92
105
|
@copy_and_hack_decorator
|
|
93
106
|
def color(
|
|
@@ -99,6 +112,9 @@ def color(
|
|
|
99
112
|
color_rvb_enabled=True,
|
|
100
113
|
color_ir_enabled=True,
|
|
101
114
|
veget_index_file="",
|
|
115
|
+
check_images=False,
|
|
116
|
+
stream_RGB="ORTHOIMAGERY.ORTHOPHOTOS",
|
|
117
|
+
stream_IRC="ORTHOIMAGERY.ORTHOPHOTOS.IRC",
|
|
102
118
|
):
|
|
103
119
|
metadata = las_info.las_info_metadata(input_file)
|
|
104
120
|
minx, maxx, miny, maxy = las_info.get_bounds_from_header_info(metadata)
|
|
@@ -122,8 +138,9 @@ def color(
|
|
|
122
138
|
if color_rvb_enabled:
|
|
123
139
|
tmp_ortho = tempfile.NamedTemporaryFile()
|
|
124
140
|
download_image_from_geoplateforme_retrying(
|
|
125
|
-
proj,
|
|
141
|
+
proj, stream_RGB, minx, miny, maxx, maxy, pixel_per_meter, tmp_ortho.name, timeout_second, check_images
|
|
126
142
|
)
|
|
143
|
+
|
|
127
144
|
pipeline |= pdal.Filter.colorization(
|
|
128
145
|
raster=tmp_ortho.name, dimensions="Red:1:256.0, Green:2:256.0, Blue:3:256.0"
|
|
129
146
|
)
|
|
@@ -132,16 +149,9 @@ def color(
|
|
|
132
149
|
if color_ir_enabled:
|
|
133
150
|
tmp_ortho_irc = tempfile.NamedTemporaryFile()
|
|
134
151
|
download_image_from_geoplateforme_retrying(
|
|
135
|
-
proj,
|
|
136
|
-
"ORTHOIMAGERY.ORTHOPHOTOS.IRC",
|
|
137
|
-
minx,
|
|
138
|
-
miny,
|
|
139
|
-
maxx,
|
|
140
|
-
maxy,
|
|
141
|
-
pixel_per_meter,
|
|
142
|
-
tmp_ortho_irc.name,
|
|
143
|
-
timeout_second,
|
|
152
|
+
proj, stream_IRC, minx, miny, maxx, maxy, pixel_per_meter, tmp_ortho_irc.name, timeout_second, check_images
|
|
144
153
|
)
|
|
154
|
+
|
|
145
155
|
pipeline |= pdal.Filter.colorization(raster=tmp_ortho_irc.name, dimensions="Infrared:1:256.0")
|
|
146
156
|
|
|
147
157
|
pipeline |= pdal.Writer.las(
|
|
@@ -158,7 +168,7 @@ def color(
|
|
|
158
168
|
|
|
159
169
|
|
|
160
170
|
def parse_args():
|
|
161
|
-
parser = argparse.ArgumentParser("Colorize tool")
|
|
171
|
+
parser = argparse.ArgumentParser("Colorize tool", formatter_class=argparse.RawTextHelpFormatter)
|
|
162
172
|
parser.add_argument("--input", "-i", type=str, required=True, help="Input file")
|
|
163
173
|
parser.add_argument("--output", "-o", type=str, default="", help="Output file")
|
|
164
174
|
parser.add_argument(
|
|
@@ -171,9 +181,39 @@ def parse_args():
|
|
|
171
181
|
parser.add_argument(
|
|
172
182
|
"--vegetation", type=str, default="", help="Vegetation file, value will be stored in Deviation field"
|
|
173
183
|
)
|
|
184
|
+
parser.add_argument("--check-images", "-c", action="store_true", help="Check that downloaded image is not white")
|
|
185
|
+
parser.add_argument(
|
|
186
|
+
"--stream-RGB",
|
|
187
|
+
type=str,
|
|
188
|
+
default="ORTHOIMAGERY.ORTHOPHOTOS",
|
|
189
|
+
help="""WMS raster stream for RGB colorization:
|
|
190
|
+
default stream (ORTHOIMAGERY.ORTHOPHOTOS) let the server choose the resolution
|
|
191
|
+
for 20cm resolution rasters, use HR.ORTHOIMAGERY.ORTHOPHOTOS
|
|
192
|
+
for 50 cm resolution rasters, use ORTHOIMAGERY.ORTHOPHOTOS.BDORTHO""",
|
|
193
|
+
)
|
|
194
|
+
parser.add_argument(
|
|
195
|
+
"--stream-IRC",
|
|
196
|
+
type=str,
|
|
197
|
+
default="ORTHOIMAGERY.ORTHOPHOTOS.IRC",
|
|
198
|
+
help="""WMS raster stream for IRC colorization. Default to ORTHOIMAGERY.ORTHOPHOTOS.IRC
|
|
199
|
+
Documentation about possible stream : https://geoservices.ign.fr/services-web-experts-ortho""",
|
|
200
|
+
)
|
|
201
|
+
|
|
174
202
|
return parser.parse_args()
|
|
175
203
|
|
|
176
204
|
|
|
177
205
|
if __name__ == "__main__":
|
|
178
206
|
args = parse_args()
|
|
179
|
-
color(
|
|
207
|
+
color(
|
|
208
|
+
input_file=args.input,
|
|
209
|
+
output_file=args.output,
|
|
210
|
+
proj=args.proj,
|
|
211
|
+
pixel_per_meter=args.resolution,
|
|
212
|
+
timeout_second=args.timeout,
|
|
213
|
+
color_rvb_enabled=args.rvb,
|
|
214
|
+
color_ir_enabled=args.ir,
|
|
215
|
+
veget_index_file=args.vegetation,
|
|
216
|
+
check_images=args.check_images,
|
|
217
|
+
stream_RGB=args.stream_RGB,
|
|
218
|
+
stream_IRC=args.stream_IRC,
|
|
219
|
+
)
|
|
File without changes
|
|
File without changes
|