diff --git a/u4py/analysis/inversion.py b/u4py/analysis/inversion.py index 3680314745aa860335bc00a19f52c7a8979f8dd0..8ebaf8020adeafd66dd8cecf6d9463b1eaed526f 100644 --- a/u4py/analysis/inversion.py +++ b/u4py/analysis/inversion.py @@ -1112,7 +1112,7 @@ def invert_test_data(): fig.tight_layout() fig.savefig( Path( - r"~\HESSENBOX-DA\Umwelt_4\Bericht_2024\images\beispiel_zeitreihe.pdf" + r"~\nextHessenbox\Umwelt_4\Bericht_2024\images\beispiel_zeitreihe.pdf" ).expanduser() ) # plt.show() diff --git a/u4py/scripts/codetests/plot_geotiff.py b/u4py/scripts/codetests/plot_geotiff.py new file mode 100644 index 0000000000000000000000000000000000000000..1a9814429cf22d6b69735c4bbeefc6489e2d1199 --- /dev/null +++ b/u4py/scripts/codetests/plot_geotiff.py @@ -0,0 +1,16 @@ +import matplotlib.pyplot as plt + +import u4py.plotting.axes as u4ax + + +def main(): + file_path = ( + r"E:\Projekte\Umwelt4\PSI_Tiffs_EGMS_2015_2021_vertikal\2016-01-05.tif" + ) + + u4ax.add_tile(file_path) + plt.show() + + +if __name__ == "__main__": + main() diff --git a/u4py/scripts/examples/algorithms/contouring.py b/u4py/scripts/examples/algorithms/contouring.py index 968a285f81d0f4c880e208fab0659ad70cbafead..1bb105b7762f6ab67c75aa95aadae9a84d765a36 100644 --- a/u4py/scripts/examples/algorithms/contouring.py +++ b/u4py/scripts/examples/algorithms/contouring.py @@ -26,7 +26,7 @@ def main(): r"~\Documents\ArcGIS\EndberichtWorkflowPlots" ).expanduser() output_path = Path( - r"~\HESSENBOX-DA\Umwelt_4\Bericht_2024\images" + r"~\nextHessenbox\Umwelt_4\Bericht_2024\images" ).expanduser() fig, axes = plt.subplots( @@ -35,7 +35,7 @@ def main(): # Original difference plan and boundary of plot logging.info("Plotting Differenzenplan") - axes[0][0].set_title("Differenzenplan") + axes[0][0].set_title("DEM difference") orig_folder = os.path.join(base_path, "original_tiffs") orig_tiffs = [ os.path.join(orig_folder, f) @@ -61,7 +61,7 @@ def main(): # Get and plot buffered shapes logging.info("Plotting Filter Masken") - axes[0][1].set_title("Filter Masken") + axes[0][1].set_title("Masking") shp_cfg = u4config.get_shape_config() shape_cache_folder = os.path.join(base_path, "shape_cache") os.makedirs(shape_cache_folder, exist_ok=True) @@ -81,7 +81,7 @@ def main(): # Plot Clipped tiffs logging.info("Plotting Clipped Tiffs") - axes[0][2].set_title("Geschnittener Differenzenplan") + axes[0][2].set_title("Filtered differences") clip_folder = os.path.join(base_path, "clipped_tiffs") clip_tiffs = [ os.path.join(clip_folder, f) @@ -93,7 +93,7 @@ def main(): # Contours logging.info("Plotting Contours") - axes[1][0].set_title("Konturierung") + axes[1][0].set_title("Contouring") u4ax.add_gpkg_data_in_axis( os.path.join(base_path, "contours.gpkg"), table="contours", @@ -106,7 +106,7 @@ def main(): # Groups logging.info("Plotting Groups") - axes[1][1].set_title("Gruppierung") + axes[1][1].set_title("Clustering") u4ax.add_gpkg_data_in_axis( os.path.join(base_path, "Classified_Shapes.gpkg"), table="Classified_Shapes", @@ -119,7 +119,7 @@ def main(): # Klassifikation logging.info("Plotting Classification") - axes[1][2].set_title("Klassifikation") + axes[1][2].set_title("Classification") gpkg_crs = u4sql.get_crs( os.path.join(base_path, "Filtered_Classified_Shapes_onlyLarge.gpkg"), "Filtered_Classified_Shapes_2410", @@ -157,9 +157,9 @@ def main(): axes[1][0].xaxis.set_major_formatter(u4pltfmt.coordinate_formatter) axes[1][1].xaxis.set_major_formatter(u4pltfmt.coordinate_formatter) axes[1][2].xaxis.set_major_formatter(u4pltfmt.coordinate_formatter) - u4pltfmt.enumerate_axes(fig) + # u4pltfmt.enumerate_axes(fig) fig.tight_layout() - fig.savefig(os.path.join(output_path, "ContourWorkflow.png")) + fig.savefig(os.path.join(output_path, "ContourWorkflow_en.png")) # fig.savefig(os.path.join(output_path, "ContourWorkflow.pdf")) diff --git a/u4py/scripts/examples/algorithms/linear_combination_parameters.py b/u4py/scripts/examples/algorithms/linear_combination_parameters.py index 1bafe075eb7eb162e2a24dc1fc64461ff6f071d1..35caece24a9eb9ad3639d796dbe7cd3351cd843a 100644 --- a/u4py/scripts/examples/algorithms/linear_combination_parameters.py +++ b/u4py/scripts/examples/algorithms/linear_combination_parameters.py @@ -69,7 +69,7 @@ def main(): fig.savefig( os.path.join( Path( - r"~\HESSENBOX-DA\Umwelt_4_privat\2023-12 HLNUG Kolloq" + r"~\nextHessenbox\Umwelt_4_privat\2023-12 HLNUG Kolloq" ).expanduser(), f"{kk}.png", ) diff --git a/u4py/scripts/examples/correlation_external_data/Groundwater_height.py b/u4py/scripts/examples/correlation_external_data/Groundwater_height.py index 093f4281a6e56b84afacdc9c2784332337244c73..ced6200aaffd82b315e6c9bf9e4c53eea95b1a35 100644 --- a/u4py/scripts/examples/correlation_external_data/Groundwater_height.py +++ b/u4py/scripts/examples/correlation_external_data/Groundwater_height.py @@ -16,12 +16,14 @@ import u4py.utils.projects as u4proj def main(): project = u4proj.get_project( proj_path=Path( - r"C:\Users\Michael Rudolf\Documents\ArcGIS\U4_projects\Groundwater_height.u4project" + r"~\Documents\ArcGIS\U4_projects\Groundwater_height.u4project" ).expanduser(), required=["base_path", "places_path", "ext_path", "diff_plan_path"], interactive=False, ) - wells_shp_path = r"C:\Users\Michael Rudolf\HESSENBOX-DA\Datenaustausch_Umwelt4.0\All_Correlations_GW_PSI.shp" + wells_shp_path = Path( + r"~\nextHessenbox\Datenaustausch_Umwelt4.0\All_Correlations_GW_PSI.shp" + ).expanduser() wells_gdf = gp.read_file(wells_shp_path) wells_path = os.path.join( project["paths"]["ext_path"], "GWStände_2015", "GWStände_2015.pkl" diff --git a/u4py/scripts/examples/regional_case_studies/NeoTect_URG_PSI_ShapeAvg.py b/u4py/scripts/examples/regional_case_studies/NeoTect_URG_PSI_ShapeAvg.py index ebb12a0cf79568ecd09be35ee203b50b2bdf490e..e466d8b63f928e7702c368503d095ae6e1e1dc3c 100644 --- a/u4py/scripts/examples/regional_case_studies/NeoTect_URG_PSI_ShapeAvg.py +++ b/u4py/scripts/examples/regional_case_studies/NeoTect_URG_PSI_ShapeAvg.py @@ -11,7 +11,7 @@ def main(): r"~\Documents\ArcGIS\INSAR_results\NeoTect_URG_PSI\Faults" ).expanduser() out_path = Path( - r"~\HESSENBOX-DA\Entwurf_Neotectonics_URG (Johannes Mair)\Python Plots" + r"~\nextHessenbox\Entwurf_Neotectonics_URG (Johannes Mair)\Python Plots" ).expanduser() fault_list = ["1A", "1B", "1C", "1D", "1E", "2A", "2B"] diff --git a/u4py/scripts/helpers/clear_merged_gpkg.py b/u4py/scripts/helpers/clear_merged_gpkg.py index 8526c242b20ce935990a71e69f0ea6e97b5b16cf..6b91e2d84b02fe05e07cae5a101eacf95c22f0f3 100644 --- a/u4py/scripts/helpers/clear_merged_gpkg.py +++ b/u4py/scripts/helpers/clear_merged_gpkg.py @@ -1,10 +1,14 @@ +from pathlib import Path + import geopandas as gp import numpy as np from tqdm import tqdm def main(): - file_path = r"c:\Users\Michael Rudolf\Documents\ArcGIS\SelectedSites_August24\Filtered_Classified_Shapes_all_merged_unclean.gpkg" + file_path = Path( + r"~\Documents\ArcGIS\SelectedSites_August24\Filtered_Classified_Shapes_all_merged_unclean.gpkg" + ).expanduser() gdf: gp.GeoDataFrame print("Loading File") gdf = gp.read_file(file_path, layer="Filtered_Classified_Shapes") diff --git a/u4py/scripts/helpers/filter_classified_shapes.py b/u4py/scripts/helpers/filter_classified_shapes.py index fb96030158a010648c3d33410c81ace2f2cc521e..03b0ecdef00dbae808e6cb7b651e71e3561eed0d 100644 --- a/u4py/scripts/helpers/filter_classified_shapes.py +++ b/u4py/scripts/helpers/filter_classified_shapes.py @@ -1,15 +1,21 @@ +from pathlib import Path + import geopandas as gp def main(): - # in_file = "C:/Users/Michael Rudolf/Documents/ArcGIS/SelectedSites_August24/Filtered_Classified_Shapes_all_merged_clean.gpkg" - # out_file = "C:/Users/Michael Rudolf/Documents/ArcGIS/SelectedSites_August24/Filtered_Classified_Shapes_2410.gpkg" + # in_file = Path("~/Documents/ArcGIS/SelectedSites_August24/Filtered_Classified_Shapes_all_merged_clean.gpkg").expanduser() + # out_file = Path("~/Documents/ArcGIS/SelectedSites_August24/Filtered_Classified_Shapes_2410.gpkg").expanduser() # gdf: gp.GeoDataFrame # gdf = gp.read_file(in_file, where="area>20000 AND volumes_moved>10000") # gdf.to_file(out_file) - in_file = r"c:\Users\Michael Rudolf\Documents\ArcGIS\SelectedSites_HLNUG_RD\RD_Rutschungen_gesamt.shp" - out_file = r"c:\Users\Michael Rudolf\Documents\ArcGIS\SelectedSites_HLNUG_RD\thresholded_contours_all_shapes.gpkg" + in_file = Path( + r"~\Documents\ArcGIS\SelectedSites_HLNUG_RD\RD_Rutschungen_gesamt.shp" + ).expanduser() + out_file = Path( + r"~\Documents\ArcGIS\SelectedSites_HLNUG_RD\thresholded_contours_all_shapes.gpkg" + ).expanduser() gdf: gp.GeoDataFrame gdf = gp.read_file(in_file) diff --git a/u4py/scripts/helpers/manual_classification_to_shp.py b/u4py/scripts/helpers/manual_classification_to_shp.py index bc21c0b41b2f593122b9bbf310e94458224b3e12..dd903d3683a0115e644c7d304c49b8ec6e66446a 100644 --- a/u4py/scripts/helpers/manual_classification_to_shp.py +++ b/u4py/scripts/helpers/manual_classification_to_shp.py @@ -35,7 +35,9 @@ def main(): # Testing classifier project = { "paths": { - "sites_path": r"C:\Users\Michael Rudolf\Documents\ArcGIS\SelectedSites_April24" + "sites_path": Path( + r"~\Documents\ArcGIS\SelectedSites_April24" + ).expanduser() } } res = dict() @@ -75,9 +77,9 @@ def get_manual_classes(file_path: os.PathLike) -> dict: classes = val.split(",") for jj, cls in enumerate(classes): if "$^{?}$" in cls: - data[f"unclear_{jj+1}"][nrow] = True + data[f"unclear_{jj + 1}"][nrow] = True cls = cls.replace("$^{?}$", "") - data[f"class_{jj+1}"][nrow] = cls + data[f"class_{jj + 1}"][nrow] = cls if ii == 2: data["comment"][nrow] = ( val.replace("$^\\circ$", "°") diff --git a/u4py/scripts/playground/bk50_to_shp.py b/u4py/scripts/playground/bk50_to_shp.py index 583ed149cce6cb2b26686bc6554e5298d4e3ab66..1b0b616706a4bccb6563198d6643871961cde4d7 100644 --- a/u4py/scripts/playground/bk50_to_shp.py +++ b/u4py/scripts/playground/bk50_to_shp.py @@ -1,3 +1,5 @@ +from pathlib import Path + import contextily import geopandas as gp import matplotlib.pyplot as plt @@ -8,7 +10,7 @@ import u4py.analysis.spatial as u4spatial def main(): - out_folder = r"c:\Users\Michael Rudolf\Documents\ArcGIS\Places\bodenkarte" + out_folder = Path(r"~\Documents\ArcGIS\Places\bodenkarte").expanduser() region = gp.GeoDataFrame( geometry=[ u4spatial.bounds_to_polygon( diff --git a/u4py/scripts/playground/filtered_classified_stats.py b/u4py/scripts/playground/filtered_classified_stats.py index ed0ba8c4351ce4f22403e92fb87b386497e876ae..e504ee2a4bd25fea79024c2602e01ad8fe367652 100644 --- a/u4py/scripts/playground/filtered_classified_stats.py +++ b/u4py/scripts/playground/filtered_classified_stats.py @@ -1,4 +1,5 @@ import os +from pathlib import Path import geopandas as gp import matplotlib.axes as max @@ -7,9 +8,9 @@ import numpy as np def main(): - folder_path = ( - r"C:\Users\Michael Rudolf\Documents\ArcGIS\SelectedSites_August24" - ) + folder_path = Path( + r"~\Documents\ArcGIS\SelectedSites_August24" + ).expanduser() flist = [ "Filtered_Classified_Shapes_hazard.gpkg", "Filtered_Classified_Shapes_onlyLarge.gpkg",