wolfhece 2.0.55__py3-none-any.whl → 2.1.1__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.
@@ -0,0 +1,29 @@
1
+ 7
2
+ 1.0
3
+ 181
4
+ 230
5
+ 90
6
+ 1.0
7
+ 99
8
+ 99
9
+ 99
10
+ 1.0
11
+ 159
12
+ 187
13
+ 215
14
+ 1.0
15
+ 181
16
+ 121
17
+ 241
18
+ 1.0
19
+ 241
20
+ 121
21
+ 99
22
+ 4.0
23
+ 221
24
+ 221
25
+ 221
26
+ 7.0
27
+ 255
28
+ 255
29
+ 190
@@ -0,0 +1,77 @@
1
+ 19
2
+ 11.0
3
+ 153
4
+ 230
5
+ 0
6
+ 12.0
7
+ 55
8
+ 168
9
+ 0
10
+ 13.0
11
+ 142
12
+ 181
13
+ 180
14
+ 20.0
15
+ 179
16
+ 179
17
+ 179
18
+ 21.0
19
+ 0
20
+ 0
21
+ 0
22
+ 22.0
23
+ 157
24
+ 157
25
+ 157
26
+ 23.0
27
+ 225
28
+ 225
29
+ 225
30
+ 31.0
31
+ 0
32
+ 133
33
+ 168
34
+ 32.0
35
+ 186
36
+ 236
37
+ 245
38
+ 33.0
39
+ 71
40
+ 214
41
+ 242
42
+ 34.0
43
+ 102
44
+ 154
45
+ 171
46
+ 41.0
47
+ 169
48
+ 0
49
+ 230
50
+ 43.0
51
+ 180
52
+ 135
53
+ 247
54
+ 51.0
55
+ 255
56
+ 0
57
+ 0
58
+ 52.0
59
+ 168
60
+ 0
61
+ 0
62
+ 53.0
63
+ 255
64
+ 127
65
+ 127
66
+ 62.0
67
+ 136
68
+ 69
69
+ 69
70
+ 66.0
71
+ 206
72
+ 136
73
+ 102
74
+ 70.0
75
+ 255
76
+ 255
77
+ 190
wolfhece/pywalous.py CHANGED
@@ -4,25 +4,191 @@ from os.path import exists, join, dirname, basename
4
4
  from os import getcwd, chdir
5
5
  from typing import Union, Literal
6
6
  import numpy as np
7
+ from pathlib import Path
8
+ import logging
9
+
10
+ import wx
11
+ import wx.grid
12
+
13
+ from .PyTranslate import _
14
+ from .PyPalette import wolfpalette
15
+
16
+ WALOUS_MAJ_NIV1 = {'Production primaire': 1.,
17
+ 'Production secondaire': 2.,
18
+ 'Production tertiaire': 3.,
19
+ 'Réseaux de transport, Logistique et réseaux d\'utilité publique': 4.,
20
+ 'Usage résidentiel': 5.,
21
+ 'Autres usages': 6.,
22
+ 'Zones naturelles': 7.}
23
+
24
+ WALOUS_MAJ_NIV2 = {'Agriculture': 11.,
25
+ 'Sylviculture': 12.,
26
+ 'Industries Extractives': 13.,
27
+ 'Aquaculture et pêche':14,
28
+ 'Production secondaire non définie': 20.,
29
+ 'Industrie de matières premières': 21.,
30
+ 'Industrie lourde': 22.,
31
+ 'Industrie légère': 23.,
32
+ 'Production d\'énergie': 24.,
33
+ 'Service commerciaux': 31.,
34
+ 'Services financiers, spécialisés et d\'information': 32.,
35
+ 'Services publics': 33.,
36
+ 'Services culturels, Services de loisirs et Services récréatifs': 34.,
37
+ 'Réseaux de transport': 41.,
38
+ 'Services Logistiques et d\'entreposage': 42.,
39
+ 'Réseau d\'utilité publique': 43.,
40
+ 'Usage résidentiel permanent': 51.,
41
+ 'Usage résidentiel avec d\'autres usages compatibles': 52.,
42
+ 'Autres usages résidentiels': 53.,
43
+ 'Zones abandonnées': 62.,
44
+ 'Usage inconnu': 66.,
45
+ 'Zones naturelles': 70.}
46
+
47
+ WALOUS_COLORMAP_MAJ_NIV1 = {1.: (181,230,90,255),
48
+ 2.: (99,99,99,255),
49
+ 3.: (159,187,215,255),
50
+ 4.: (181,121,241,255),
51
+ 5.: (241,121,99,255),
52
+ 6.: (221,221,221,255),
53
+ 7.: (255,255,190,255)}
54
+
55
+ WALOUS_COLORMAP_MAJ_NIV2 = {11.: (153,230,0,255),
56
+ 12.: (55,168,0,255),
57
+ 13.: (142,181,180,255),
58
+ 14.: (172,250,192,255),
59
+ 20.: (179,179,179,255),
60
+ 21.: (0,0,0,255),
61
+ 22.: (157,157,157,255),
62
+ 23.: (225,225,225,255),
63
+ 24.: (79,79,79,255),
64
+ 31.: (0,133,168,255),
65
+ 32.: (186,236,245,255),
66
+ 33.: (71,214,242,255),
67
+ 34.: (102,154,171,255),
68
+ 41.: (169,0,230,255),
69
+ 42.: (213,196,245,255),
70
+ 43.: (180,135,247,255),
71
+ 51.: (255,0,0,255),
72
+ 52.: (168,0,0,255),
73
+ 53.: (255,127,127,255),
74
+ 62.: (136,69,69,255),
75
+ 66.: (206,136,102,255),
76
+ 70.: (255,255,190,255)}
77
+
78
+ def get_palette_walous(which:Literal['MAJ_NIV1', 'MAJ_NIV2']) -> wolfpalette:
79
+ """
80
+ Get the palette for WALOUS
81
+
82
+ :return : palette
83
+ """
84
+
85
+ locpal = wolfpalette()
86
+ locpal.interval_cst = True
87
+ locpal.automatic = False
88
+
89
+ if which == 'MAJ_NIV1':
90
+ locpal.set_values_colors(values = list(WALOUS_MAJ_NIV1.values()),
91
+ colors = list(WALOUS_COLORMAP_MAJ_NIV1.values()))
92
+ elif which == 'MAJ_NIV2':
93
+ locpal.set_values_colors(values = list(WALOUS_MAJ_NIV2.values()),
94
+ colors = list(WALOUS_COLORMAP_MAJ_NIV2.values()))
95
+ else:
96
+ logging.error('Unknown WALOUS level')
97
+
98
+ return locpal
99
+
100
+ def update_palette_walous(which:Literal['MAJ_NIV1', 'MAJ_NIV2'], pal:wolfpalette):
101
+ """
102
+ Update the palette for WALOUS MAJ_NIV1
103
+
104
+ :param pal : palette to update
105
+ :return : updated palette
106
+ """
107
+
108
+ if which == 'MAJ_NIV1':
109
+ for k, v in WALOUS_COLORMAP_MAJ_NIV1.items():
110
+ pal.set_values_colors(values = list(WALOUS_MAJ_NIV1.values()),
111
+ colors = list(WALOUS_COLORMAP_MAJ_NIV1.values()))
112
+ elif which == 'MAJ_NIV2':
113
+ for k, v in WALOUS_COLORMAP_MAJ_NIV2.items():
114
+ pal.set_values_colors(values = list(WALOUS_MAJ_NIV2.values()),
115
+ colors = list(WALOUS_COLORMAP_MAJ_NIV2.values()))
116
+
117
+ pal.interval_cst = True
118
+ pal.automatic = False
119
+
120
+ return 0
121
+
122
+
123
+ WALOUS2MANNING_MAJ_NIV1 = {1.: 0.04,
124
+ 2.: 0.02,
125
+ 3.: 0.02,
126
+ 4.: 0.03,
127
+ 5.: 0.025,
128
+ 6.: 0.04,
129
+ 7.: 0.05}
130
+
131
+ WALOUS2MANNING_MAJ_NIV2 = {11.: 0.04, # Agriculture
132
+ 12.: 0.04, # Sylviculture
133
+ 13.: 0.04, # Industries Extractives
134
+ 14.: 0.04, # Aquaculture et pêche
135
+ 20.: 0.03, # Production secondaire non définie
136
+ 21.: 0.03, # Industrie de matières premières
137
+ 22.: 0.03, # Industrie lourde
138
+ 23.: 0.03, # Industrie légère
139
+ 24.: 0.03, # Production d'énergie
140
+ 31.: 0.02, # Service commerciaux
141
+ 32.: 0.02, # Services financiers, spécialisés et d'information
142
+ 33.: 0.02, # Services publics
143
+ 34.: 0.02, # Services culturels, Services de loisirs et Services récréatifs
144
+ 41.: 0.025, # Réseaux de transport
145
+ 42.: 0.02, # Services Logistiques et d'entreposage
146
+ 43.: 0.025, # Réseau d'utilité publique
147
+ 51.: 0.025, # Usage résidentiel permanent
148
+ 52.: 0.025, # Usage résidentiel avec d'autres usages compatibles
149
+ 53.: 0.025, # Autres usages résidentiels
150
+ 62.: 0.04, # Zones abandonnées
151
+ 66.: 0.04, # Usage inconnu
152
+ 70.: 0.05} # Zones naturelles
7
153
 
8
154
  class Walous_data():
155
+ """
156
+ La donnée Walous est liée à l'utilisation des sols en Wallonie
157
+
158
+ source : https://geoportail.wallonie.be/walous
159
+
160
+ Cette classe permet la manipulation de la donnée dans le cadre du projet MODREC
161
+ et plus spécifiquement la distribution d'un coefficient de frottement sur base
162
+ de la donnée Walous.
163
+
164
+ """
9
165
 
10
166
  def __init__(self,
11
167
  dir_data:str = '',
12
168
  fn:str = 'WAL_UTS__2018_L72',
13
169
  bounds:Union[list[float, float, float, float],list[list[float, float], list[float, float]]] = None) -> None:
170
+ """
171
+ Constructor
172
+
173
+ :param dir_data : directory of the data
174
+ :param fn : filename without extension (shp)
175
+ :param bounds : Two ways to set spatial bounds -- [xmin, ymin, xmax, ymax] or [[xmin, xmax], [ymin, ymax]]
176
+
177
+ """
178
+
179
+ self._dir = dir_data # directory of the data
180
+ self._fn = fn # filename without extension
181
+ self._gdf = None # geopandas dataframe
14
182
 
15
- self._dir = dir_data
16
- self._fn = fn
17
- self._gdf = None
18
183
  if bounds is not None:
184
+ # Bounds are set -> read file
19
185
  self.read(True, bounds=bounds)
20
186
 
21
187
  def read(self,
22
188
  force:bool = False,
23
189
  bounds:Union[list[float, float, float, float],list[list[float, float], list[float, float]]] = None):
24
190
  """
25
- Read the file
191
+ Read data from file
26
192
 
27
193
  :param force : force to read even read was done before
28
194
  :param bounds : [xmin, ymin, xmax, ymax] or [[xmin, xmax], [ymin, ymax]]
@@ -31,106 +197,294 @@ class Walous_data():
31
197
  if self._gdf is None or force:
32
198
  assert self._dir!="" and self._fn != ''
33
199
 
34
- if exists(join(self._dir, self._fn+'.shp')):
200
+ filepath = (Path(self._dir)/ self._fn).with_suffix('.shp')
201
+
202
+ if filepath.exists():
35
203
  if bounds is not None:
36
204
  if len(bounds)==2:
205
+ # [[xmin, xmax], [ymin, ymax]]
37
206
  xmin = bounds[0][0]
38
207
  xmax = bounds[0][1]
39
208
  ymin = bounds[1][0]
40
209
  ymax = bounds[1][1]
41
210
  else:
211
+ # [xmin, ymin, xmax, ymax]
42
212
  xmin = bounds[0]
43
213
  xmax = bounds[2]
44
214
  ymin = bounds[1]
45
215
  ymax = bounds[3]
46
216
 
47
- self._gdf = gpd.read_file(join(self._dir, self._fn+'.shp'), bbox=(xmin,ymin,xmax,ymax))
217
+ # read part of the file
218
+ self._gdf = gpd.read_file(str(filepath), bbox=(xmin,ymin,xmax,ymax))
48
219
  else:
49
- self._gdf = gpd.read_file(join(self._dir, self._fn+'.shp'))
220
+ # read all
221
+ self._gdf = gpd.read_file(str(filepath))
50
222
 
51
223
  # self._gdf['MAJ_NIV2'] = np.asarray(self._gdf['MAJ_NIV2'], dtype=int)
52
224
  # self._gdf['MAJ_NIV3'] = np.asarray(self._gdf['MAJ_NIV3'], dtype=int) # ne fonctionne pas car le niveau 3 contient des lettres --> à généraliser
53
225
  else:
54
226
  self._gdf = None
55
227
 
56
- def write(self, fnout:str=''):
228
+ def write(self, fnout:str='out_clip.shp'):
229
+ """
230
+ Write _gdf to file
231
+
232
+ :param fnout : output filename
233
+ """
234
+
235
+ try:
236
+ curdir = getcwd()
237
+ detsdir = dirname(fnout)
57
238
 
58
- if fnout=='':
59
- fnout = 'out_clip.shp'
239
+ chdir(detsdir)
60
240
 
61
- curdir = getcwd()
62
- detsdir = dirname(fnout)
241
+ self._gdf.to_file(basename(fnout))
63
242
 
64
- chdir(detsdir)
243
+ chdir(curdir)
244
+ return 0
65
245
 
66
- self._gdf.to_file(basename(fnout))
246
+ except:
247
+ logging.error('Error in writing data - Walous module')
248
+ return -1
67
249
 
68
- chdir(curdir)
69
250
 
70
- def to_file(self, fn):
251
+ def to_file(self, fn:str='out_clip.shp'):
71
252
  """
72
- link to write
253
+ Alias to write
254
+
255
+ :param fn : output filename
73
256
  """
257
+
74
258
  self.write(fn)
75
259
 
76
260
  def rasterize(self,
77
- bounds:Union[list[float, float, float, float],list[list[float, float], list[float, float]]] = None,
261
+ bounds:Union[list[float, float, float, float],list[list[float, float], list[float, float]]],
78
262
  layer:Literal['MAJ_NIV1','MAJ_NIV2'] ='MAJ_NIV1',
79
- mapping = None,
80
263
  fn_out:str = 'out.tif',
81
264
  pixel_size:float = 0.5,
82
- NoData_value:float = -9999.,
265
+ NoData_value:float = -99999.,
83
266
  num_type = gdal.GDT_Float32
84
267
  ):
85
268
 
86
269
  """
87
270
  Rasterization of polygon data to tif
271
+
272
+ :param bounds : [xmin, ymin, xmax, ymax] or [[xmin, xmax], [ymin, ymax]]
273
+ :param layer : layer to rasterize
274
+ :param fn_out : output filename
275
+ :param pixel_size : pixel size
276
+ :param NoData_value : NoData value
277
+ :param num_type : type of the number
88
278
  """
279
+
89
280
  if bounds is None:
281
+ logging.error('Bounds must be set')
90
282
  return None
283
+ else:
284
+ if len(bounds)==4:
285
+ # [[xmin, xmax], [ymin, ymax]]
286
+ bounds = [[bounds[0], bounds[2]], [bounds[1], bounds[3]]]
91
287
 
92
288
  if self._gdf is None:
289
+ logging.info('Reading data')
93
290
  self.read(bounds=bounds)
291
+ logging.info('End of reading data')
94
292
 
95
293
  if self._gdf is None:
294
+ logging.error('No data to rasterize')
96
295
  return None
97
296
 
98
297
  if layer not in self._gdf.keys():
298
+ logging.error('Layer not found in the data')
99
299
  return None
100
300
 
101
- self.write(fn_out + '.shp')
102
- self._gdf['Mapping'] = np.float32(self._gdf[layer])
301
+ ret = self.write(str(fn_out) + '.shp')
302
+
303
+ if ret !=0:
304
+ logging.error('An error occured in writing the data to file')
305
+ return -1
306
+
307
+ try:
308
+
309
+ # Add a new column for mapping based on the desired layer
310
+ self._gdf['Mapping'] = np.float32(self._gdf[layer])
311
+
312
+ if layer == 'MAJ_NIV2':
313
+ self._gdf['Mapping'] = np.float32(self._gdf['Mapping'].replace('_', ''))
314
+
315
+ source_ds:ogr.DataSource
316
+ source_layer:ogr.Layer
317
+
318
+ source_ds = ogr.Open(self._gdf.to_json())
319
+
320
+ # source_srs:ogr.
321
+ source_layer = source_ds.GetLayer()
322
+ source_srs = source_layer.GetSpatialRef()
323
+
324
+ # Create the destination data source
325
+ x_res = int((bounds[0][1] - bounds[0][0]) / pixel_size)
326
+ y_res = int((bounds[1][1] - bounds[1][0]) / pixel_size)
327
+
328
+ driver:gdal.Driver
329
+ driver = gdal.GetDriverByName('GTiff')
330
+ target_ds = driver.Create(str(fn_out), x_res, y_res, 1, num_type)
331
+
332
+ target_ds:gdal.Dataset
333
+ band:gdal.Band
334
+ target_ds.SetGeoTransform((bounds[0][0], pixel_size, 0, bounds[1][1], 0, -pixel_size))
335
+ band = target_ds.GetRasterBand(1)
336
+ band.SetNoDataValue(NoData_value)
337
+
338
+ target_ds.SetProjection(source_srs.ExportToWkt())
339
+
340
+ # Rasterize
341
+ gdal.RasterizeLayer(target_ds,
342
+ [1], source_layer,
343
+ options = ["ALL_TOUCHED=TRUE", "ATTRIBUTE=Mapping"])
344
+
345
+ target_ds = None
346
+
347
+ return fn_out
348
+
349
+ except:
350
+ logging.error('Error in rasterization')
351
+ return -2
352
+
353
+
354
+ class DlgMapWalous(wx.Dialog):
355
+ """ Modal dialog for mapping WALOUS value to another ones """
356
+
357
+ def __init__(self, parent, title:str = _("Mapping WALOUS value to ..."), which:str = 'MAJ_NIV1'):
358
+
359
+ super(DlgMapWalous, self).__init__(parent, title=title, size=(450, 400))
360
+
361
+ panel = wx.Panel(self)
362
+
363
+ sizer = wx.BoxSizer(wx.VERTICAL)
364
+
365
+ self._table = wx.grid.Grid(panel)
366
+
367
+ if which == 'MAJ_NIV1':
368
+ self._table.CreateGrid(len(WALOUS_MAJ_NIV1), 3)
369
+ self._table.SetColLabelValue(0, _("Name"))
370
+ self._table.SetColLabelValue(1, _("Value"))
371
+ self._table.SetColLabelValue(2, _("Manning 'n'"))
372
+ self._table.HideRowLabels()
373
+
374
+ for i, (k, v) in enumerate(WALOUS_MAJ_NIV1.items()):
375
+ self._table.SetCellValue(i, 0, str(k))
376
+ self._table.SetCellValue(i, 1, str(v))
377
+ self._table.SetCellValue(i, 2, str(WALOUS2MANNING_MAJ_NIV1[v]))
378
+ self._table.SetCellAlignment(i, 1, wx.ALIGN_CENTER, wx.ALIGN_CENTER)
379
+ self._table.SetCellAlignment(i, 2, wx.ALIGN_CENTER, wx.ALIGN_CENTER)
380
+
381
+ elif which == 'MAJ_NIV2':
382
+ self._table.CreateGrid(len(WALOUS_MAJ_NIV2), 3)
383
+ self._table.SetColLabelValue(0, _("Name"))
384
+ self._table.SetColLabelValue(1, _("Value"))
385
+ self._table.SetColLabelValue(2, _("Manning 'n'"))
386
+ self._table.HideRowLabels()
387
+
388
+ for i, (k, v) in enumerate(WALOUS_MAJ_NIV2.items()):
389
+ self._table.SetCellValue(i, 0, str(k))
390
+ self._table.SetCellValue(i, 1, str(v))
391
+ self._table.SetCellValue(i, 2, str(WALOUS2MANNING_MAJ_NIV2[v]))
392
+ self._table.SetCellAlignment(i, 1, wx.ALIGN_CENTER, wx.ALIGN_CENTER)
393
+ self._table.SetCellAlignment(i, 2, wx.ALIGN_CENTER, wx.ALIGN_CENTER)
394
+
395
+ self._table.SetColFormatFloat(1, 2, 0)
396
+ self._table.SetColFormatFloat(2, 6, 4)
397
+ self._table.SetColSize(0, 250)
398
+ self._table.SetColSize(1, 50)
399
+ self._table.SetColSize(2, 100)
400
+
401
+
402
+ sizer.Add(self._table, 1, wx.EXPAND)
403
+ panel.SetSizer(sizer)
404
+
405
+ sizer_btns = wx.BoxSizer(wx.HORIZONTAL)
406
+ btn_ok = wx.Button(panel, wx.ID_OK, _("OK"))
407
+ btn_cancel = wx.Button(panel, wx.ID_CANCEL, _("Cancel"))
408
+ sizer_btns.Add(btn_ok, 0, wx.ALL, 5)
409
+ sizer_btns.Add(btn_cancel, 0, wx.ALL, 5)
410
+
411
+ sizer.Add(sizer_btns, 0, wx.ALIGN_CENTER)
412
+
413
+ self.Bind(wx.EVT_BUTTON, self.on_ok, btn_ok)
414
+ self.Bind(wx.EVT_BUTTON, self.on_cancel, btn_cancel)
415
+
416
+ self.Center()
417
+
418
+ def on_ok(self, event):
419
+ self.EndModal(wx.ID_OK)
420
+
421
+ def on_cancel(self, event):
422
+ self.EndModal(wx.ID_CANCEL)
423
+
424
+ def get_mapping(self) -> dict:
425
+
426
+ retdict = {}
427
+
428
+ try:
429
+ for i in range(self._table.GetNumberRows()):
430
+ retdict[float(self._table.GetCellValue(i, 1))] = float(self._table.GetCellValue(i, 2))
431
+ except:
432
+ retdict = -1
433
+ logging.error('Error in getting mapping')
434
+
435
+ return retdict
436
+
437
+
438
+ class WalousLegend(wx.Dialog):
439
+ """ Show the legend of WALOUS """
440
+
441
+ def __init__(self, *args, **kw):
442
+ super().__init__(*args, **kw, size = (400, 650))
443
+
444
+ panel = wx.Panel(self)
445
+ sizer = wx.BoxSizer(wx.VERTICAL)
103
446
 
104
- source_ds:ogr.DataSource
105
- source_layer:ogr.Layer
447
+ self._text_v1 = wx.StaticText(panel, label=_("WALOUS MAJ_NIV1"))
448
+ self._text_v2 = wx.StaticText(panel, label=_("WALOUS MAJ_NIV2"))
106
449
 
107
- source_ds = ogr.Open(self._gdf.to_json())
450
+ self._legend_v1 = wx.grid.Grid(panel)
451
+ self._legend_v1.CreateGrid(len(WALOUS_MAJ_NIV1), 3)
452
+ self._legend_v1.SetColSize(0, 200)
453
+ self._legend_v1.SetColLabelValue(0, _("Name"))
454
+ self._legend_v1.SetColLabelValue(1, _("Value"))
455
+ self._legend_v1.SetColLabelValue(2, _("Color"))
456
+ self._legend_v1.HideRowLabels()
108
457
 
109
- # source_srs:ogr.
110
- source_layer = source_ds.GetLayer()
111
- source_srs = source_layer.GetSpatialRef()
458
+ for i, (k, v) in enumerate(WALOUS_MAJ_NIV1.items()):
459
+ self._legend_v1.SetCellValue(i, 0, str(k))
460
+ self._legend_v1.SetCellValue(i, 1, str(v))
461
+ self._legend_v1.SetCellBackgroundColour(i, 2, WALOUS_COLORMAP_MAJ_NIV1[v])
112
462
 
113
- # Create the destination data source
114
- x_res = int((bounds[0][1] - bounds[0][0]) / pixel_size)
115
- y_res = int((bounds[1][1] - bounds[1][0]) / pixel_size)
463
+ self._legend_v2 = wx.grid.Grid(panel)
464
+ self._legend_v2.CreateGrid(len(WALOUS_MAJ_NIV2), 3)
465
+ self._legend_v2.SetColLabelValue(0, _("Name"))
466
+ self._legend_v2.SetColSize(0, 200)
467
+ self._legend_v2.SetColLabelValue(1, _("Value"))
468
+ self._legend_v2.SetColLabelValue(2, _("Color"))
469
+ self._legend_v2.HideRowLabels()
116
470
 
117
- driver:gdal.Driver
118
- driver = gdal.GetDriverByName('GTiff')
119
- target_ds = driver.Create(fn_out, x_res, y_res, 1, num_type)
471
+ for i, (k, v) in enumerate(WALOUS_MAJ_NIV2.items()):
472
+ self._legend_v2.SetCellValue(i, 0, str(k))
473
+ self._legend_v2.SetCellValue(i, 1, str(v))
474
+ self._legend_v2.SetCellBackgroundColour(i, 2, WALOUS_COLORMAP_MAJ_NIV2[v])
120
475
 
121
- target_ds:gdal.Dataset
122
- band:gdal.Band
123
- target_ds.SetGeoTransform((bounds[0][0], pixel_size, 0, bounds[1][1], 0, -pixel_size))
124
- band = target_ds.GetRasterBand(1)
125
- band.SetNoDataValue(NoData_value)
476
+ sizer.Add(self._text_v1, 0, wx.EXPAND, border=5)
477
+ sizer.Add(self._legend_v1, 1, wx.EXPAND, border=5)
478
+ sizer.Add(self._text_v2, 0, wx.EXPAND, border=5)
479
+ sizer.Add(self._legend_v2, 1, wx.EXPAND, border=5)
126
480
 
127
- target_ds.SetProjection(source_srs.ExportToWkt())
481
+ panel.SetSizer(sizer)
482
+ self.Center()
128
483
 
129
- # Rasterize
130
- gdal.RasterizeLayer(target_ds,
131
- [1], source_layer,
132
- options = ["ALL_TOUCHED=TRUE", "ATTRIBUTE=Mapping"])
484
+ self.Show()
133
485
 
134
- target_ds = None
486
+ def __del__(self):
487
+ self.Destroy()
135
488
 
136
- return fn_out
489
+ def close(self):
490
+ self.Destroy()
@@ -442,6 +442,8 @@ class Config_Manager_2D_GPU:
442
442
  else:
443
443
  # ajout du fichier dans la liste
444
444
  curdict[ext].append(locpath)
445
+ else:
446
+ pass
445
447
 
446
448
  elif curel.is_dir():
447
449
  if curel.name.startswith('__'):
@@ -545,10 +547,17 @@ class Config_Manager_2D_GPU:
545
547
  curdict[IS_SIMUL] = ok
546
548
 
547
549
  def _test_is_scenario(self, curdict:dict):
550
+ """ Teste si le répertoire contient des fichiers de scénario """
551
+
552
+ ok = False
553
+
554
+ ok |= len(curdict[GPU_2D_file_extensions.TIF.value])>0
555
+ ok |= len(curdict[GPU_2D_file_extensions.TIFF.value])>0
556
+
557
+ for sublist in curdict[GPU_2D_file_extensions.PY.value].values():
558
+ ok |= len(sublist)>0
548
559
 
549
- curdict[IS_SCENARIO] = len(curdict[GPU_2D_file_extensions.TIF.value])>0 or \
550
- len(curdict[GPU_2D_file_extensions.TIFF.value])>0 or \
551
- len(curdict[GPU_2D_file_extensions.PY.value])>0
560
+ curdict[IS_SCENARIO] = ok
552
561
 
553
562
  def _test_is_results(self, curdict:dict):
554
563
  """ Teste si le répertoire contient des fichiers de résultats """
@@ -635,8 +644,8 @@ class Config_Manager_2D_GPU:
635
644
  if len(all_tif_infil)>0:
636
645
  create_vrt_from_files_first_based(all_tif_infil, from_path / '__infil_assembly.vrt')
637
646
 
638
- def create_vec(self,
639
- from_path:Path,
647
+ def create_vec(self,
648
+ from_path:Path,
640
649
  which:Literal['bath', 'mann', 'infil'] = 'bath') -> Zones:
641
650
  """ Create a vec file from a path """
642
651