bedrock-ge 0.2.0__py3-none-any.whl → 0.2.2__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.
bedrock_ge/gi/write.py ADDED
@@ -0,0 +1,105 @@
1
+ from pathlib import Path
2
+ from typing import Dict, Union
3
+
4
+ import geopandas as gpd
5
+ import pandas as pd
6
+
7
+
8
+ def write_gi_db_to_gpkg(
9
+ brgi_db: Dict[str, gpd.GeoDataFrame],
10
+ gpkg_path: Union[str, Path],
11
+ ) -> None:
12
+ """
13
+ Write a database, i.e. a dictionary of DataFrames, with Bedrock Ground Investigation data to a GeoPackage file.
14
+
15
+ Each DataFrame will be saved in a separate table named after the keys of the dictionary.
16
+
17
+ Args:
18
+ brgi_dfs (dict): A dictionary where keys are brgi table names and values are DataFrames with brgi data.
19
+ gpkg_path (str): The name of the output GeoPackage file.
20
+
21
+ Returns:
22
+ None: This function does not return any value. It writes the DataFrames to a GeoPackage file.
23
+ """
24
+
25
+ # Create a GeoDataFrame from the dictionary of DataFrames
26
+ for sheet_name, brgi_table in brgi_db.items():
27
+ sanitized_table_name = sanitize_table_name(sheet_name)
28
+
29
+ if isinstance(brgi_table, pd.DataFrame):
30
+ brgi_table = gpd.GeoDataFrame(brgi_table)
31
+
32
+ if isinstance(brgi_table, gpd.GeoDataFrame):
33
+ brgi_table.to_file(
34
+ gpkg_path, driver="GPKG", layer=sanitized_table_name, overwrite=True
35
+ )
36
+
37
+ print(f"Ground Investigation data has been written to '{gpkg_path}'.")
38
+
39
+
40
+ def write_gi_db_to_excel(
41
+ gi_db: Dict[str, Union[pd.DataFrame, gpd.GeoDataFrame]],
42
+ excel_path: Union[str, Path],
43
+ ) -> None:
44
+ """
45
+ Write a database, i.e. a dictionary of DataFrames, with Ground Investigation data to an Excel file.
46
+
47
+ Each DataFrame will be saved in a separate sheet named after the keys of the dictionary.
48
+ Function can be used on any GI database, whether in AGS, Bedrock, or another format.
49
+
50
+ Args:
51
+ gi_dfs (dict): A dictionary where keys are GI table names and values are DataFrames with GI data.
52
+ excel_path (str): The name of the output Excel file.
53
+
54
+ Returns:
55
+ None: This function does not return any value. It writes the DataFrames to an Excel file.
56
+ """
57
+
58
+ # Create an Excel writer object
59
+ with pd.ExcelWriter(excel_path, engine="openpyxl") as writer:
60
+ for sheet_name, df in gi_db.items():
61
+ sanitized_sheet_name = sanitize_table_name(sheet_name)
62
+ if isinstance(df, pd.DataFrame) or isinstance(df, gpd.GeoDataFrame):
63
+ df.to_excel(writer, sheet_name=sanitized_sheet_name, index=False)
64
+
65
+ print(f"Ground Investigation data has been written to '{excel_path}'.")
66
+
67
+
68
+ def sanitize_table_name(sheet_name):
69
+ """
70
+ Replace invalid characters and spaces in GI table names with underscores,
71
+ such that the name is consistent with SQL, GeoPackage and Excel naming conventions.
72
+
73
+ Args:
74
+ sheet_name (str): The original sheet name.
75
+
76
+ Returns:
77
+ str: A sanitized sheet name with invalid characters and spaces replaced.
78
+ """
79
+ # Trim to a maximum length of 31 characters
80
+ trimmed_name = sheet_name.strip()[:31]
81
+
82
+ # Define invalid characters and replace with underscores
83
+ invalid_chars = [":", "/", "\\", "?", "*", "[", "]"]
84
+ sanitized_name = trimmed_name
85
+ for char in invalid_chars:
86
+ sanitized_name = sanitized_name.replace(char, "_")
87
+
88
+ # Replace spaces with underscores
89
+ sanitized_name = sanitized_name.replace(" ", "_")
90
+
91
+ # Collapse multiple underscores to one
92
+ sanitized_name = "_".join(filter(None, sanitized_name.split("_")))
93
+
94
+ if trimmed_name != sanitized_name:
95
+ print(
96
+ f"Table names shouldn't contain {invalid_chars} or spaces and shouldn't be longer than 31 characters.\n",
97
+ f"Replaced '{sheet_name}' with '{sanitized_name}'.",
98
+ )
99
+
100
+ # Ensure name isn't empty after sanitization
101
+ if not sanitized_name:
102
+ sanitized_name = "Table1"
103
+ print("The table name was completely invalid or empty. Replaced with 'Table1'.")
104
+
105
+ return sanitized_name
bedrock_ge/plot.py ADDED
@@ -0,0 +1,2 @@
1
+ def hello_plt() -> None:
2
+ print("Hello from src/bedrock/plot.py!")
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bedrock-ge
3
- Version: 0.2.0
4
- Summary: Bedrock, the Open Source Foundation for Ground Engineering
3
+ Version: 0.2.2
4
+ Summary: Bedrock's Python library for geotechnical engineering.
5
5
  Project-URL: Homepage, https://bedrock.engineer/
6
6
  Project-URL: Source, https://github.com/bedrock-engineer/bedrock-ge
7
7
  Project-URL: Documentation, https://bedrock.engineer/docs/
@@ -9,18 +9,26 @@ Project-URL: Tracker, https://github.com/bedrock-engineer/bedrock-ge/issues
9
9
  Author-email: Bedrock <info@bedrock.engineer>
10
10
  License: Apache Software License (Apache 2.0)
11
11
  License-File: LICENSE
12
- Keywords: aec,ags,bedrock,bim,engineering geology,geo-bim,geotech,geotechnical data,geotechnical engineering,gi data,gis,ground engineering,ground investigation,ground investigation data
13
- Classifier: Development Status :: 2 - Pre-Alpha
12
+ Keywords: aec,aeco,ags,ags3,ags4,bedrock,bim,borehole,borehole-data,civil-engineering,engineering-geology,geo-bim,geoscience-bim,geosciences,geospatial,geospatial-data,geostatistics,geotech,geotechnical,geotechnical-data,geotechnical-engineering,geotechnics,gi-data,gis,ground-engineering,ground-investigation,ground-investigation-data,subsurface,underground
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Intended Audience :: Education
15
+ Classifier: Intended Audience :: Science/Research
14
16
  Classifier: License :: OSI Approved :: Apache Software License
15
17
  Classifier: Operating System :: OS Independent
16
- Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python
19
+ Classifier: Programming Language :: Python :: 3 :: Only
20
+ Classifier: Programming Language :: Python :: 3.9
21
+ Classifier: Programming Language :: Python :: 3.10
22
+ Classifier: Programming Language :: Python :: 3.11
23
+ Classifier: Programming Language :: Python :: 3.12
24
+ Classifier: Programming Language :: Python :: 3.13
25
+ Classifier: Topic :: Scientific/Engineering
26
+ Classifier: Topic :: Scientific/Engineering :: GIS
17
27
  Requires-Python: >=3.9
18
- Requires-Dist: duckdb~=1.0
19
28
  Requires-Dist: geopandas~=1.0
20
29
  Requires-Dist: openpyxl~=3.0
21
30
  Requires-Dist: pandera>=0.23.0
22
31
  Requires-Dist: python-ags4~=1.0
23
- Requires-Dist: sqlglot>=26.12.0
24
32
  Requires-Dist: sqlmodel>=0.0.22
25
33
  Description-Content-Type: text/markdown
26
34
 
@@ -209,7 +217,7 @@ Please start a [discussion](https://github.com/orgs/bedrock-gi/discussions) or c
209
217
 
210
218
  Hi, I'm Joost Gevaert 👋
211
219
 
212
- I studied geotechnical engineering and applied geophysics and then worked for [Arup](https://www.arup.com/) for 4 as a geotechnical engineer an computational designer.
220
+ I studied geotechnical engineering and applied geophysics and then worked for [Arup](https://www.arup.com/) for 4 years as a geotechnical engineer and computational designer.
213
221
 
214
222
  During my time at Arup I worked a lot on bringing computational design into the world of geotechnical engineering, and on [bridging the gaps between geotechnical engineering and structural engineering](https://www.linkedin.com/posts/joost-gevaert_lightbim-lightbim-lightbim-activity-7234726439835549697-3xdO).
215
223
 
@@ -0,0 +1,21 @@
1
+ bedrock_ge/__init__.py,sha256=F2GWz69tVD2wVnMHeHrp-TWuguF3xjlReB1CiPeK-lM,89
2
+ bedrock_ge/plot.py,sha256=hUxpZXWlUmf2Ec5CKkGkOBJ_TfC1KM8yUeuMtsqk7A0,70
3
+ bedrock_ge/gi/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
+ bedrock_ge/gi/bedrock-gi-schema.json,sha256=XaumYqouiflu4Nc8ChyFSHpmpJW4YPG0hsyeSxkuIWQ,850
5
+ bedrock_ge/gi/concatenate.py,sha256=kdK6TRu6dzUKeRALAqP3Az75PDTROe3rXfUaMXrCu-c,1462
6
+ bedrock_ge/gi/gis_geometry.py,sha256=f-J0OYQoi-ZXGslbo5qSXaBYphIpDB_igtUVMKi3Rzw,9316
7
+ bedrock_ge/gi/schemas.py,sha256=ZA2wFQOevXtN57XglY-M70TzbZY2RyLHJDRUkmz47_M,2871
8
+ bedrock_ge/gi/sqlmodels.py,sha256=_h3H9UP91I_1Ya_SZuL6gZbqL7uNCd5Y-u-yTf7CNto,2253
9
+ bedrock_ge/gi/validate.py,sha256=km5PeAUDRQr_RhwUG606I0SAdNrHmMA0RYpg7TU95Dc,4664
10
+ bedrock_ge/gi/write.py,sha256=vSHcj3xfWTyFJCa065Xfu4PBZddCPrYZ7MeW9M8PoUM,3863
11
+ bedrock_ge/gi/ags/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
+ bedrock_ge/gi/ags/ags3_data_dictionary.json,sha256=Wx20_oJRdAlzEo-cKD6FgN9B9zOMDTcsp5dgc8QWofI,188588
13
+ bedrock_ge/gi/ags/ags4_data_dictionary.json,sha256=XE5XJNo8GBPZTUPgvVr3QgO1UfEIAxzlSeXi-P1VLTs,609670
14
+ bedrock_ge/gi/ags/read.py,sha256=ebBHfU-w0BkjvcfmmmBxJx-PyziBRNm_4Okzvvqime8,7078
15
+ bedrock_ge/gi/ags/schemas.py,sha256=y36n9SCKqFfoIQ_7-MTEdfArA5vAqZdRpY3wC4fdjy4,7451
16
+ bedrock_ge/gi/ags/transform.py,sha256=8szmnYiQfAg-DSDMC1vqDVtSEZOCUifKGKaTyrVSqa0,8351
17
+ bedrock_ge/gi/ags/validate.py,sha256=Wghxm0dFGQB-6qrsbxOf68YalnPdJ6oeCXZJ7xrYVHI,703
18
+ bedrock_ge-0.2.2.dist-info/METADATA,sha256=UylRTVrQB-2s_hzPLvNJvyazh0hEn35g8b2rH2IkpEQ,14317
19
+ bedrock_ge-0.2.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
20
+ bedrock_ge-0.2.2.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
21
+ bedrock_ge-0.2.2.dist-info/RECORD,,
@@ -1,4 +0,0 @@
1
- bedrock_ge-0.2.0.dist-info/METADATA,sha256=D3sGpuyeQc2RhQeAYUTPFROyZRhBlKkdIMkv6dB1hnY,13712
2
- bedrock_ge-0.2.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
3
- bedrock_ge-0.2.0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
4
- bedrock_ge-0.2.0.dist-info/RECORD,,