@@ -49,6 +49,7 @@ def run_cover(
4949 logger .warning ("This is a POC for a cover marker, so not for operational use!" )
5050 logger .info (f"Config used: \n { conf .pformat_config ()} " )
5151
52+ force = True
5253 markertype = conf .marker ["markertype" ]
5354 if not markertype .startswith (("COVER" , "ONBEDEKT" )):
5455 raise ValueError (f"Invalid markertype { markertype } , expected COVER_XXX" )
@@ -88,7 +89,9 @@ def run_cover(
8889 OR "ALL_BEST" like '%TBG%'
8990 OR "ALL_BEST" like '%EBG%'
9091 """
91- gfo .copy_layer (input_parcel_path , input_parcel_filtered_path , where = where )
92+ gfo .copy_layer (
93+ input_parcel_path , input_parcel_filtered_path , where = where , force = force
94+ )
9295 input_parcel_path = input_parcel_filtered_path
9396
9497 elif markertype == "COVER_EEB_VOORJAAR" :
@@ -100,7 +103,9 @@ def run_cover(
100103 where = (
101104 "ALL_BEST like '%EEB%' AND GWSCOD_V = '83' AND GWSCOD_H IN ('201', '202')"
102105 )
103- gfo .copy_layer (input_parcel_path , input_parcel_filtered_path , where = where )
106+ gfo .copy_layer (
107+ input_parcel_path , input_parcel_filtered_path , where = where , force = force
108+ )
104109 input_parcel_path = input_parcel_filtered_path
105110
106111 elif markertype in ("COVER_TBG_BMG_VOORJAAR" , "COVER_TBG_BMG_NAJAAR" ):
@@ -110,7 +115,9 @@ def run_cover(
110115 input_parcel_filtered_path = input_preprocessed_dir / input_parcel_filename
111116
112117 where = "ALL_BEST like '%TBG%' OR ALL_BEST like '%BMG%'"
113- gfo .copy_layer (input_parcel_path , input_parcel_filtered_path , where = where )
118+ gfo .copy_layer (
119+ input_parcel_path , input_parcel_filtered_path , where = where , force = force
120+ )
114121 input_parcel_path = input_parcel_filtered_path
115122
116123 else :
@@ -144,6 +151,7 @@ def run_cover(
144151 input_parcel_path = input_parcel_path ,
145152 output_imagedata_parcel_input_path = imagedata_input_parcel_path ,
146153 output_parcel_nogeo_path = input_parcel_nogeo_path ,
154+ force = force ,
147155 )
148156
149157 # STEP 2: Calculate the timeseries data needed
@@ -165,6 +173,7 @@ def run_cover(
165173 end_date = end_date ,
166174 images_to_use = images_to_use ,
167175 timeseries_periodic_dir = timeseries_periodic_dir ,
176+ force = force ,
168177 )
169178
170179 # STEP 3: Determine the cover for the parcels for all periods
@@ -175,7 +184,7 @@ def run_cover(
175184 )
176185 cover_dir = run_dir / input_parcel_nogeo_path .stem
177186 cover_dir .mkdir (parents = True , exist_ok = True )
178- force = False
187+
179188 on_error = "warn"
180189 parcels_cover_paths = []
181190
@@ -238,10 +247,12 @@ def run_cover(
238247 cols_to_keep = [* list (input_info .columns ), "pred1" ]
239248 if "provincie" in parcels_selected .columns :
240249 cols_to_keep .append ("provincie" )
250+
241251 parcels_selected = (
242252 parcels_selected [[* cols_to_keep , "pred1_prob" ]]
243- .groupby (cols_to_keep , dropna = False , as_index = False )
244- .max ()
253+ .sort_values ("pred1_prob" , ascending = False )
254+ .groupby (conf .columns ["id" ], dropna = False , as_index = False )
255+ .first () # Take the highest pred1_prob per id
245256 )
246257
247258 # Add pred_consolidated based on max pred1_proba
@@ -268,7 +279,7 @@ def _categorize_pred(x):
268279 return "NODATA"
269280 try :
270281 x_num = float (x )
271- if x_num >= 0.5 :
282+ if x_num > 0.5 :
272283 return "ONBEDEKT"
273284 elif x_num > 0.4 :
274285 return "DOUBT"
@@ -295,7 +306,7 @@ def _calc_cover(
295306 if force :
296307 gfo .remove (output_path )
297308 elif output_geo_path is not None and not output_geo_path .exists ():
298- # Geo file is asked bu missing: we need to recalculate the output file as
309+ # Geo file is asked but missing: we need to recalculate the output file as
299310 # well because we need temporary files to create the geo file.
300311 gfo .remove (output_path )
301312 else :
0 commit comments