@@ -193,12 +193,13 @@ def select_best_products_per_feature(self) -> GeoDataFrame:
193
193
self .vector_features_with_products = spatial_join_results
194
194
return self .vector_features_with_products
195
195
196
- def to_file (self ) :
196
+ def to_file (self , output_dir : Union [ str , pathlib . Path ]) -> None :
197
197
write_results_to_file (
198
198
cloud_cover = self .max_cloud_cover ,
199
199
successful_results = self .successful_results ,
200
200
incomplete_results = self .incomplete_results ,
201
201
error_results = self .error_results ,
202
+ output_dir = output_dir ,
202
203
)
203
204
204
205
@@ -322,25 +323,26 @@ def write_results_to_file(
322
323
successful_results : dict ,
323
324
incomplete_results : Optional [list ] = None ,
324
325
error_results : Optional [list ] = None ,
326
+ output_dir : Union [str , pathlib .Path ] = DATA_DIR ,
325
327
logger : logging .Logger = LOGGER ,
326
328
) -> dict :
327
- tile_filename = DATA_DIR / f"data_lt{ cloud_cover } cc.json"
329
+ tile_filename = output_dir / f"data_lt{ cloud_cover } cc.json"
328
330
with open (tile_filename , "w" , encoding = "utf-8" ) as json_file :
329
331
json .dump (successful_results , json_file , indent = 4 )
330
332
logger .info (f"Results have been written to { tile_filename } " )
331
333
332
334
incomplete_filename = "None"
333
335
if incomplete_results :
334
336
incomplete_dict = {"incomplete" : incomplete_results }
335
- incomplete_filename = DATA_DIR / f"incomplete_lt{ cloud_cover } cc.json"
337
+ incomplete_filename = output_dir / f"incomplete_lt{ cloud_cover } cc.json"
336
338
with open (incomplete_filename , "w" , encoding = "utf-8" ) as json_file :
337
339
json .dump (incomplete_dict , json_file , indent = 4 )
338
340
logger .info (f"Incomplete results have been written to { incomplete_filename } " )
339
341
340
342
error_filename = "None"
341
343
if error_results :
342
344
error_dict = {"errors" : error_results }
343
- error_filename = DATA_DIR / f"errors_lt{ cloud_cover } cc.json"
345
+ error_filename = output_dir / f"errors_lt{ cloud_cover } cc.json"
344
346
with open (error_filename , "w" , encoding = "utf-8" ) as json_file :
345
347
json .dump (error_dict , json_file , indent = 4 )
346
348
logger .info (f"Errors results have been written to { error_filename } " )
0 commit comments