def writeQualityIndicatorsToCsvFile( class_count, precision_list, recall_list, fscore_list, performance_list, TFP_class_list, TFN_class_list, quantity_rate_list, class_list, overall_accuracy, overall_fscore, overall_performance, kappa, indicators_output_file, overwrite, textures_list): check = os.path.isfile(indicators_output_file) if check and not overwrite: print(cyan + "writeQualityIndicatorsToCsvFile() : " + bold + yellow + "Result file quality indicators exists." + '\n' + endC) else: # verifier si les info textures existes if textures_list is None: # Tente de supprimer le fichier try: removeFile(indicators_output_file) except Exception: #Ignore l'exception levee si le fichier n'existe pas (et ne peut donc pas être supprime) pass else: # Ecriture du nom de la texture texture_characteristics = textures_list[0] texture_name = str(texture_characteristics[0]) channel = str(texture_characteristics[1]) radius = str(texture_characteristics[2]) text_texture = "Name : %s ; Channel : %s ; Radius : %s \n" % ( texture_name, channel, radius) appendTextFile(indicators_output_file, text_texture) print(cyan + "writeQualityIndicatorsToCsvFile() : " + bold + green + "Writing file quality indicators..." + '\n' + endC) # contenu texte des indicateurs text_indicators = "Overall Accuracy ; Overall F1-Score ; Overall Performance ; Kappa \n %f ; %f ; %f ; %f \n\n" % ( overall_accuracy, overall_fscore, overall_performance, kappa) text_class_list = " Class " text_precision_list = " Precision " text_recall_list = " Recall " text_f_scores_list = " F1-Scores " text_performance_list = " Performance " text_TFP_class_list = " TFP_class " text_TFN_class_list = " TFN_class " text_quantity_rate_list = " Quantity_rate " for i in range(class_count): text_class_list += " ; %d" % (class_list[i]) text_precision_list += " ; %f" % (precision_list[i]) text_recall_list += " ; %f" % (recall_list[i]) text_f_scores_list += " ; %f" % (fscore_list[i]) text_performance_list += " ; %f" % (performance_list[i]) text_TFP_class_list += " ; %f" % (TFP_class_list[i]) text_TFN_class_list += " ; %f" % (TFN_class_list[i]) text_quantity_rate_list += " ; %f" % (quantity_rate_list[i]) text_File_list = text_class_list + "\n" \ + text_precision_list + "\n" \ + text_recall_list + "\n" \ + text_f_scores_list + "\n" \ + text_performance_list + "\n" \ + text_TFP_class_list + "\n" \ + text_TFN_class_list + "\n" \ + text_quantity_rate_list + "\n\n" \ + text_indicators + "\n" try: appendTextFile(indicators_output_file, text_File_list) except Exception: raise NameError( cyan + "writeQualityIndicatorsToCsvFile() : " + bold + red + "An error occured during writing " + indicators_output_file + " file quality indicators. See error message above." + endC) print(cyan + "writeQualityIndicatorsToCsvFile() : " + bold + green + "Quality indicators writed on file" + '\n' + endC) return
text += " - Fichiers route de la BD TOPO : " + str(roads_files_list) + "\n" text += " - Méthode de calcul des indicateurs : " + str(indicators_method) + "\n" text += " - Méthode de calcul des UCZ : " + str(ucz_method) + "\n" text += " - Système de gestion de base de données (SGBD) : " + str(dbms_choice) + "\n" if not enter_with_mask and (indicators_method == "BD_exogenes" or indicators_method == "SI_seuillage"): text += " - Seuil de NDVI pour l'extraction de la végétation : " + str(threshold_ndvi) + "\n" if indicators_method == "SI_seuillage": text += " - Seuil de NDVI pour l'extraction de l'eau : " + str(threshold_ndvi_water) + "\n" text += " - Seuil de NDWI2 pour l'extraction de l'eau : " + str(threshold_ndwi2) + "\n" text += " - Seuil inférieur du BI pour l'extraction du sol nu : " + str(threshold_bi_bottom) + "\n" text += " - Seuil supérieur du BI pour l'extraction du sol nu : " + str(threshold_bi_top) + "\n" text += " ##########" + "\n" appendTextFile(path_time_log,text) ################################################## ### Lancement des calculs, appel des fonctions ### ################################################## etape1 = raw_input(bold + blue + "Lancer la préparation des données ? (Y/N) :" + endC + " ") while etape1 not in ("Y","N"): print(bold + yellow + "Attention : veuillez répondre par Y ou N." + endC) etape1 = raw_input(bold + blue + "Lancer la préparation des données ? (Y/N) :" + endC + " ") print("\n") if etape1 == "Y": if not enter_with_mask: preparationRasters(urbanatlas_input, ucz_output, emprise_file, mask_file, enter_with_mask, image_file, mnh_file, built_files_list, hydrography_file, roads_files_list, rpg_file, indicators_method, ucz_method, dbms_choice, threshold_ndvi, threshold_ndvi_water, threshold_ndwi2, threshold_bi_bottom, threshold_bi_top, 0, path_time_log, temp_directory, FORMAT_RASTER, FORMAT_VECTOR, EXTENSION_RASTER) preparationVecteurs(urbanatlas_input, ucz_output, emprise_file, mask_file, enter_with_mask, image_file, mnh_file, built_files_list, hydrography_file, roads_files_list, rpg_file, indicators_method, ucz_method, dbms_choice, threshold_ndvi, threshold_ndvi_water, threshold_ndwi2, threshold_bi_bottom, threshold_bi_top, path_time_log, temp_directory, FORMAT_VECTOR, EXTENSION_VECTOR)
def distanceTDCPointLine(input_points_shp, input_tdc_shp, output_dir, input_sea_points, evolution_column_name, path_time_log, server_postgis="localhost", user_postgis="postgres", password_postgis="postgres", database_postgis="db_buffer_tdc", schema_name="directionevolution", port_number=5432, epsg=2154, project_encoding="UTF-8", format_vector="ESRI Shapefile", save_results_intermediate=True, overwrite=True): # Mise à jour du Log starting_event = "distanceTDCPointLine() : Distance TDC Point Line starting : " timeLine(path_time_log, starting_event) if debug >= 3: print(bold + green + "Variables dans distanceTDCPointLine - Variables générales" + endC) print(cyan + "distanceTDCPointLine() : " + endC + "input_points_shp : " + str(input_points_shp) + endC) print(cyan + "distanceTDCPointLine() : " + endC + "input_tdc_shp : " + str(input_tdc_shp) + endC) print(cyan + "distanceTDCPointLine() : " + endC + "output_dir : " + str(output_dir) + endC) print(cyan + "distanceTDCPointLine() : " + endC + "input_sea_points : " + str(input_sea_points) + endC) print(cyan + "distanceTDCPointLine() : " + endC + "evolution_column_name : " + str(evolution_column_name) + endC) print(cyan + "distanceTDCPointLine() : " + endC + "path_time_log : " + str(path_time_log) + endC) print(cyan + "distanceTDCPointLine() : " + endC + "server_postgis : " + str(server_postgis) + endC) print(cyan + "distanceTDCPointLine() : " + endC + "user_postgis : " + str(user_postgis) + endC) print(cyan + "distanceTDCPointLine() : " + endC + "password_postgis : " + str(password_postgis) + endC) print(cyan + "distanceTDCPointLine() : " + endC + "database_postgis : " + str(database_postgis) + endC) print(cyan + "distanceTDCPointLine() : " + endC + "schema_name : " + str(schema_name) + endC) print(cyan + "distanceTDCPointLine() : " + endC + "port_number : " + str(port_number) + endC) print(cyan + "distanceTDCPointLine() : " + endC + "epsg : " + str(epsg) + endC) print(cyan + "distanceTDCPointLine() : " + endC + "project_encoding : " + str(project_encoding) + endC) print(cyan + "distanceTDCPointLine() : " + endC + "format_vector : " + str(format_vector) + endC) print(cyan + "distanceTDCPointLine() : " + endC + "save_results_inter : " + str(save_results_intermediate) + endC) print(cyan + "distanceTDCPointLine() : " + endC + "overwrite : " + str(overwrite) + endC) print(bold + green + "## START : DistanceTDCPointLine" + endC) # Initialisation des constantes EXT_TEXT = ".txt" # Configuration du format vecteur driver = ogr.GetDriverByName(format_vector) # Création de la référence spatiale srs = osr.SpatialReference() srs.ImportFromEPSG(epsg) # Constitution des noms ext_vect = os.path.splitext(os.path.split(input_points_shp)[1])[1] input_points_shp_name = os.path.splitext( os.path.split(input_points_shp)[1])[0] input_tdc_shp_name = os.path.splitext(os.path.split(input_tdc_shp)[1])[0] vector_output_points = output_dir + os.sep + "distance_" + input_points_shp_name + "_" + input_tdc_shp_name + ext_vect output_text_file = output_dir + os.sep + "distance_sens_evol_" + input_points_shp_name + "_" + input_tdc_shp_name + EXT_TEXT vector_output_points_sens = output_dir + os.sep + "distance_sens_evol_" + input_points_shp_name + "_" + input_tdc_shp_name + ext_vect ## Gestion des fichiers # Création du répertoire de sortie s'il n'existe pas déjà if not os.path.exists(output_dir): os.makedirs(output_dir) # Suppression de la couche en sortie si elle existe déjà if os.path.exists(vector_output_points): driver.DeleteDataSource(vector_output_points) # Suppression de la couche en sortie si elle existe déjà if os.path.exists(vector_output_points_sens): driver.DeleteDataSource(vector_output_points_sens) ## Ouverture des fichiers existants # Ouverture de la couche points data_source_points_ref = driver.Open(input_points_shp, 0) input_layer_pts = data_source_points_ref.GetLayer() input_layer_pts_defn = input_layer_pts.GetLayerDefn() # Ouverture de la couche TDC data_source_tdc = driver.Open(input_tdc_shp, 0) input_layer_tdc = data_source_tdc.GetLayer(0) ## Création des fichiers de sortie # Création de la couche en sortie output_data_source = driver.CreateDataSource(vector_output_points) output_layer = output_data_source.CreateLayer(input_points_shp_name, srs, geom_type=ogr.wkbPoint) output_layer_defn = output_layer.GetLayerDefn() # Ajouter les champs du fichier d'entrée au shapefile de sortie for i in range(0, input_layer_pts_defn.GetFieldCount()): field_defn = input_layer_pts_defn.GetFieldDefn(i) output_layer.CreateField(field_defn) # Ajout du champ "distance" à la couche en sortie dist_field = ogr.FieldDefn("distance", ogr.OFTReal) output_layer.CreateField(dist_field) liste_all_distances = [] liste_min_distances = [] # Ajout des valeurs à la couche de sortie for i in range(0, input_layer_pts.GetFeatureCount()): # Récupération de l'entité de la couche en entrée input_feature = input_layer_pts.GetFeature(i) # Calcul de la distance du point courant à la ligne la plus proche geom_point = input_feature.GetGeometryRef() input_layer_tdc.ResetReading() liste_distances = [] for ligne in input_layer_tdc: geom_ligne = ligne.GetGeometryRef() dist = geom_point.Distance(geom_ligne) liste_distances.append(dist) liste_all_distances.append(dist) dist_min = min(liste_distances) liste_min_distances.append(dist_min) # Création de l'entité en sortie output_feature = ogr.Feature(output_layer_defn) # Ajout des champs de la couche d'entrée à la couche de sortie if debug >= 4: print(cyan + "distanceTDCPointLine : " + endC + green + bold + "POINT " + str(i) + endC) for i in range(0, output_layer_defn.GetFieldCount() - 1): if debug >= 4: print(cyan + "distanceTDCPointLine : " + endC + str(output_layer_defn.GetFieldDefn(i).GetNameRef()) + " : " + str(input_feature.GetField(i))) output_feature.SetField( output_layer_defn.GetFieldDefn(i).GetNameRef(), input_feature.GetField(i)) output_feature.SetField("distance", dist_min) if debug >= 4: print(cyan + "distanceTDCPointLine : " + endC + "Distance à la ligne la plus proche : " + str(dist_min) + "\n") # Géométrie de la couche de sortie input_geom = input_feature.GetGeometryRef() output_feature.SetGeometry(input_geom) # Ajout de la nouvelle entité à la couche de sortie output_layer.CreateFeature(output_feature) ## Calcul du sens de l'évolution tdc_reference_buffers_sens = evolvingDirectionTDC( input_tdc_shp, input_sea_points, output_dir, int(ceil(max(liste_min_distances))), path_time_log, server_postgis, user_postgis, password_postgis, database_postgis, schema_name, port_number, epsg, project_encoding, format_vector, save_results_intermediate, overwrite) data_source_tdc_ref_buffers_sens = driver.Open(tdc_reference_buffers_sens, 1) layer_tdc_ref_buffers_sens = data_source_tdc_ref_buffers_sens.GetLayer(0) # Création de l'intersection avec les buffers unilatéraux pour avoir le sens d'évolution data_source_intersection_sens = driver.CreateDataSource( vector_output_points_sens) intersection_sens_layer = data_source_intersection_sens.CreateLayer( vector_output_points_sens, srs, geom_type=ogr.wkbPoint) intersection_sens_layer_defn = intersection_sens_layer.GetLayerDefn() intersection_sens = layer_tdc_ref_buffers_sens.Intersection( output_layer, intersection_sens_layer) # Ajout champ evolution, multiplication du buffer multiple dans lequel il se trouve avec sens évolution evolution_field = ogr.FieldDefn("evolution", ogr.OFTReal) intersection_sens_layer.CreateField(evolution_field) for i in range(0, intersection_sens_layer.GetFeatureCount()): feature = intersection_sens_layer.GetFeature(i) distance = feature.GetField("distance") evol_direction = feature.GetField("num_side") feature.SetField(evolution_column_name, distance * evol_direction) intersection_sens_layer.SetFeature(feature) feature.Destroy() liste_all_evolutions = [] ## Création du fichier texte en sortie writeTextFile(output_text_file, "") # Initialisation des colonnes du fichier texte for i in range(intersection_sens_layer_defn.GetFieldCount() - 1): appendTextFile( output_text_file, intersection_sens_layer_defn.GetFieldDefn(i).GetName() + "\t \t") appendTextFile(output_text_file, str(evolution_column_name) + " (m)\n") for i in range(0, intersection_sens_layer.GetFeatureCount()): # Récupération de l'entité de la couche en entrée feature = intersection_sens_layer.GetFeature(i) for j in range(0, intersection_sens_layer_defn.GetFieldCount() - 1): appendTextFile(output_text_file, str(feature.GetField(j)) + "\t \t") appendTextFile(output_text_file, str(feature.GetField(evolution_column_name)) + "\n") liste_all_evolutions.append(feature.GetField(evolution_column_name)) appendTextFile( output_text_file, "\nDistance min à la ligne (m) : " + str(min(liste_all_evolutions)) + "\n") appendTextFile( output_text_file, "Distance max à la ligne (m) : " + str(max(liste_all_evolutions)) + "\n") appendTextFile( output_text_file, "Moyenne des distances à la ligne (m) : " + str(np.mean(liste_all_evolutions)) + "\n") appendTextFile( output_text_file, "Ecart-type des distances à la ligne (m) : " + str(np.std(liste_all_evolutions)) + "\n") if debug >= 3: print(cyan + "distanceTDCPointLine() : " + endC + bold + green + "L'évolution a bien été calculée dans le fichier " + endC + bold + green + vector_output_points_sens + " dans la colonne '" + evolution_column_name + "' et la distance en valeur absolue dans la colonne 'distance'" + endC) print(cyan + "distanceTDCPointLine() : " + endC + bold + green + "Un résumé est fait dans le fichier texte : " + output_text_file + endC) # Mise à jour du Log ending_event = "distanceTDCPointLine() : Distance TDC Point Line ending : " timeLine(path_time_log, ending_event) return
def classificationUCZ(urbanatlas_input, ucz_output, emprise_file, mask_file, enter_with_mask, image_file, mnh_file, built_files_list, hydrography_file, roads_files_list, rpg_file, indicators_method, ucz_method, dbms_choice, threshold_ndvi, threshold_ndvi_water, threshold_ndwi2, threshold_bi_bottom, threshold_bi_top, no_data_value, path_time_log, format_raster='GTiff', format_vector='ESRI Shapefile', extension_raster=".tif", extension_vector=".shp", save_results_intermediate=False, overwrite=True): ####################################### ### Gestion des éventuelles erreurs ### ####################################### if indicators_method == "BD_exogenes": if threshold_ndvi == [] and not enter_with_mask: print( bold + red + "Erreur : veuillez renseigner la valeur du seuil nécessaire au calcul d'imperméabilité." + endC, file=sys.stderr) exit(1) if mask_file == "" and image_file == "": print( bold + red + "Erreur : veuillez renseigner un fichier raster à traiter (image sat ou masque végétation)." + endC, file=sys.stderr) exit(1) if built_files_list == [] or hydrography_file == "" or rpg_file == "": print( bold + red + "Erreur : veuillez bien renseigner les fichiers vecteurs à traiter (BD TOPO bati et hydrographie + RPG)." + endC, file=sys.stderr) exit(1) elif indicators_method == "SI_seuillage": if threshold_ndvi == [] or threshold_ndvi_water == [] or threshold_ndwi2 == [] or threshold_bi_bottom == [] or threshold_bi_top == []: print( bold + red + "Erreur : veuillez renseigner les valeurs de seuils nécessaires au calcul d'imperméabilité." + endC, file=sys.stderr) exit(1) if image_file == "": print(bold + red + "Erreur : veuillez renseigner l'image satellite à traiter." + endC) exit(1) if built_files_list == [] or roads_files_list == []: print( bold + red + "Erreur : veuillez bien renseigner les fichiers vecteurs à traiter (BD TOPO bati et route)." + endC, file=sys.stderr) exit(1) elif indicators_method == "SI_classif": if image_file == "": print( bold + red + "Erreur : veuillez renseigner le fichier raster résultat de la classification OCS." + endC, file=sys.stderr) exit(1) if built_files_list == []: print( bold + red + "Erreur : veuillez renseigner le fichier vecteur BD TOPO bati à traiter." + endC) exit(1) elif indicators_method == "Resultats_classif": if image_file == "": print( bold + red + "Erreur : veuillez renseigner le fichier raster résultat de la classification OCS." + endC, file=sys.stderr) exit(1) if mnh_file == "": print( bold + red + "Erreur : veuillez renseigner le fichier raster MNH associé à la classification OCS." + endC, file=sys.stderr) exit(1) ######################################################### ### Pas d'erreurs, lancement de la classification UCZ ### ######################################################### if not os.path.exists(ucz_output) or overwrite: print(green + "Début de la classification en Zones Climatiques Urbaines :" + endC) print(bold + " Nom du fichier Urban Atlas en entrée : " + endC + str(urbanatlas_input)) print(bold + " Nom du fichier classif UCZ en sortie : " + endC + str(ucz_output)) print(bold + " Fichier d'emprise de la zone d'étude : " + endC + str(emprise_file)) if indicators_method == "BD_exogenes" or indicators_method == "SI_seuillage": if enter_with_mask: print(bold + " Masque binaire de la végétation : " + endC + str(mask_file)) else: print(bold + " Image satellite : " + endC + str(image_file)) elif indicators_method == "SI_classif" or indicators_method == "Resultats_classif": print(bold + " Résultat de classification OCS : " + endC + str(image_file)) if indicators_method == "Resultats_classif": print(bold + " Modèle Numérique de Hauteur : " + endC + str(mnh_file)) if indicators_method in ("BD_exogenes", "SI_seuillage", "SI_classif"): print(bold + " Fichiers bâti de la BD TOPO : " + endC + str(built_files_list)) if indicators_method == "BD_exogenes": print(bold + " Fichier hydrographie de la BD TOPO : " + endC + str(hydrography_file)) print(bold + " Fichier RPG : " + endC + str(rpg_file)) elif indicators_method == "SI_seuillage": print(bold + " Fichiers route de la BD TOPO : " + endC + str(roads_files_list)) print(bold + " Méthode de calcul des indicateurs : " + endC + str(indicators_method)) print(bold + " Méthode de calcul des UCZ : " + endC + str(ucz_method)) print(bold + " Système de gestion de base de données (SGBD) : " + endC + str(dbms_choice)) if not enter_with_mask and (indicators_method == "BD_exogenes" or indicators_method == "SI_seuillage"): print(bold + " Seuil de NDVI pour l'extraction de la végétation : " + endC + str(threshold_ndvi)) if indicators_method == "SI_seuillage": print(bold + " Seuil de NDVI pour l'extraction de l'eau : " + endC + str(threshold_ndvi_water)) print(bold + " Seuil de NDWI2 pour l'extraction de l'eau : " + endC + str(threshold_ndwi2)) print( bold + " Seuil inférieur du BI pour l'extraction du sol nu : " + endC + str(threshold_bi_bottom)) print( bold + " Seuil supérieur du BI pour l'extraction du sol nu : " + endC + str(threshold_bi_top)) print("\n") ###################################################### ### Préparations diverses en amont des traitements ### ###################################################### if os.path.exists(ucz_output): removeVectorFile(ucz_output) temp_directory = os.path.dirname(ucz_output) + os.sep + "TEMP" if os.path.exists(temp_directory): shutil.rmtree(temp_directory) if not os.path.exists(temp_directory): try: os.makedirs(temp_directory) except Exception as err: e = "OS error: {0}".format(err) print(e, file=sys.stderr) print( bold + red + "Une erreur est apparue à la création des sous-dossiers de traitements, voir ci-dessus." + endC, file=sys.stderr) sys.exit(2) ######################################################################### ### Préparation du fichier log, écriture des paramètres du traitement ### ######################################################################### text = "Lancement d'une classification en Zones Climatiques Urbaines :" + "\n" text += " - Nom du fichier Urban Atlas en entrée : " + str( urbanatlas_input) + "\n" text += " - Nom du fichier classif UCZ en sortie : " + str( ucz_output) + "\n" text += " - Fichier d'emprise de la zone d'étude : " + str( emprise_file) + "\n" if indicators_method == "BD_exogenes" or indicators_method == "SI_seuillage": if enter_with_mask: text += " - Masque binaire de la végétation : " + str( mask_file) + "\n" else: text += " - Image satellite : " + str(image_file) + "\n" elif indicators_method == "SI_classif" or indicators_method == "Resultats_classif": text += " - Résultat de classification OCS : " + str( image_file) + "\n" if indicators_method == "Resultats_classif": text += " - Modèle Numérique de Hauteur : " + str( mnh_file) + "\n" if indicators_method in ("BD_exogenes", "SI_seuillage", "SI_classif"): text += " - Fichiers bâti de la BD TOPO : " + str( built_files_list) + "\n" if indicators_method == "BD_exogenes": text += " - Fichier hydrographie de la BD TOPO : " + str( hydrography_file) + "\n" text += " - Fichier RPG : " + str(rpg_file) + "\n" elif indicators_method == "SI_seuillage": text += " - Fichiers route de la BD TOPO : " + str( roads_files_list) + "\n" text += " - Méthode de calcul des indicateurs : " + str( indicators_method) + "\n" text += " - Méthode de calcul des UCZ : " + str(ucz_method) + "\n" text += " - Système de gestion de base de données (SGBD) : " + str( dbms_choice) + "\n" if not enter_with_mask and (indicators_method == "BD_exogenes" or indicators_method == "SI_seuillage"): text += " - Seuil de NDVI pour l'extraction de la végétation : " + str( threshold_ndvi) + "\n" if indicators_method == "SI_seuillage": text += " - Seuil de NDVI pour l'extraction de l'eau : " + str( threshold_ndvi_water) + "\n" text += " - Seuil de NDWI2 pour l'extraction de l'eau : " + str( threshold_ndwi2) + "\n" text += " - Seuil inférieur du BI pour l'extraction du sol nu : " + str( threshold_bi_bottom) + "\n" text += " - Seuil supérieur du BI pour l'extraction du sol nu : " + str( threshold_bi_top) + "\n" text += " ##########" + "\n" appendTextFile(path_time_log, text) ################################################## ### Lancement des calculs, appel des fonctions ### ################################################## # Préparation des données if not enter_with_mask: preparationRasters(urbanatlas_input, ucz_output, emprise_file, mask_file, enter_with_mask, image_file, mnh_file, built_files_list, hydrography_file, roads_files_list, rpg_file, indicators_method, ucz_method, dbms_choice, threshold_ndvi, threshold_ndvi_water, threshold_ndwi2, threshold_bi_bottom, threshold_bi_top, no_data_value, path_time_log, temp_director, format_raster, format_vector, extension_raster) preparationVecteurs(urbanatlas_input, ucz_output, emprise_file, mask_file, enter_with_mask, image_file, mnh_file, built_files_list, hydrography_file, roads_files_list, rpg_file, indicators_method, ucz_method, dbms_choice, threshold_ndvi, threshold_ndvi_water, threshold_ndwi2, threshold_bi_bottom, threshold_bi_top, path_time_log, temp_directory, extension_vector) if indicators_method == "Resultats_classif": preparationBatiOCS(urbanatlas_input, ucz_output, emprise_file, mask_file, enter_with_mask, image_file, mnh_file, built_files_list, hydrography_file, roads_files_list, rpg_file, indicators_method, ucz_method, dbms_choice, threshold_ndvi, threshold_ndvi_water, threshold_ndwi2, threshold_bi_bottom, threshold_bi_top, path_time_log, temp_directory, format_vector, extension_raster, extension_vector) text = " ##########" + "\n" appendTextFile(path_time_log, text) # Préparation au calcul des indicateurs indicateurSI(urbanatlas_input, ucz_output, emprise_file, mask_file, enter_with_mask, image_file, mnh_file, built_files_list, hydrography_file, roads_files_list, rpg_file, indicators_method, ucz_method, dbms_choice, threshold_ndvi, threshold_ndvi_water, threshold_ndwi2, threshold_bi_bottom, threshold_bi_top, path_time_log, temp_directory, extension_raster, extension_vector) indicateurRA(urbanatlas_input, ucz_output, emprise_file, mask_file, enter_with_mask, image_file, mnh_file, built_files_list, hydrography_file, roads_files_list, rpg_file, indicators_method, ucz_method, dbms_choice, threshold_ndvi, threshold_ndvi_water, threshold_ndwi2, threshold_bi_bottom, threshold_bi_top, path_time_log, temp_directory, extension_raster, extension_vector) if ucz_method == "Combinaison_avec_rugosite" or ucz_method == "Hierarchie_avec_rugosite": indicateurRug(urbanatlas_input, ucz_output, emprise_file, mask_file, enter_with_mask, image_file, mnh_file, built_files_list, hydrography_file, roads_files_list, rpg_file, indicators_method, ucz_method, dbms_choice, threshold_ndvi, threshold_ndvi_water, threshold_ndwi2, threshold_bi_bottom, threshold_bi_top, path_time_log, temp_directory, extension_raster, extension_vector) text = " ##########" + "\n" appendTextFile(path_time_log, text) # Fin du calcul des indicateurs, et étape finale de classification UCZ if dbms_choice == "SpatiaLite": traitementsSpatiaLite(urbanatlas_input, ucz_output, emprise_file, mask_file, enter_with_mask, image_file, mnh_file, built_files_list, hydrography_file, roads_files_list, rpg_file, indicators_method, ucz_method, dbms_choice, threshold_ndvi, threshold_ndvi_water, threshold_ndwi2, threshold_bi_bottom, threshold_bi_top, path_time_log, temp_directory, extension_vector) elif dbms_choice == "PostGIS": traitementsPostGIS(urbanatlas_input, ucz_output, emprise_file, mask_file, enter_with_mask, image_file, mnh_file, built_files_list, hydrography_file, roads_files_list, rpg_file, indicators_method, ucz_method, dbms_choice, threshold_ndvi, threshold_ndvi_water, threshold_ndwi2, threshold_bi_bottom, threshold_bi_top, path_time_log, temp_directory) text = " ##########" + "\n" + "\n" appendTextFile(path_time_log, text) # Nettoyage des données temporaires if not save_results_intermediate: shutil.rmtree(temp_directory) print(green + "Fin de la classification en Zones Climatiques Urbaines : " + endC + ucz_output) else: print(bold + red + "La classification UCZ '" + ucz_output + "' existe déjà." + endC, file=sys.stderr) print("\n")