bedrock-ge 0.2.2__py3-none-any.whl → 0.2.3__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/__init__.py CHANGED
@@ -1,3 +1,3 @@
1
1
  """Bedrock, the open source foundation for ground engineering."""
2
2
 
3
- __version__ = "0.2.2"
3
+ __version__ = "0.2.3"
bedrock_ge/gi/ags/read.py CHANGED
@@ -8,8 +8,7 @@ from bedrock_ge.gi.ags.validate import check_ags_proj_group
8
8
 
9
9
 
10
10
  def ags_to_dfs(ags_data: str) -> Dict[str, pd.DataFrame]:
11
- """
12
- Convert AGS 3 or AGS 4 data to a dictionary of pandas DataFrames.
11
+ """Converts AGS 3 or AGS 4 data to a dictionary of pandas DataFrames.
13
12
 
14
13
  Args:
15
14
  ags_data (str): The AGS data as a string.
@@ -52,16 +51,15 @@ def ags_to_dfs(ags_data: str) -> Dict[str, pd.DataFrame]:
52
51
 
53
52
 
54
53
  def ags3_to_dfs(ags3_data: str) -> Dict[str, pd.DataFrame]:
55
- """Convert AGS 3 data to a dictionary of pandas DataFrames.
54
+ """Converts AGS 3 data to a dictionary of pandas DataFrames.
56
55
 
57
56
  Args:
58
- ags_data (str): The AGS 3 data as a string.
57
+ ags3_data (str): The AGS 3 data as a string.
59
58
 
60
59
  Returns:
61
60
  Dict[str, pd.DataFrame]: A dictionary of pandas DataFrames, where each key represents a group name from AGS 3 data,
62
61
  and the corresponding value is a pandas DataFrame containing the data for that group.
63
62
  """
64
-
65
63
  # Initialize dictionary and variables used in the AGS 3 read loop
66
64
  ags3_dfs = {}
67
65
  line_type = "line_0"
@@ -152,10 +150,10 @@ def ags3_to_dfs(ags3_data: str) -> Dict[str, pd.DataFrame]:
152
150
 
153
151
 
154
152
  def ags4_to_dfs(ags4_data: str) -> Dict[str, pd.DataFrame]:
155
- """Convert AGS 4 data to a dictionary of pandas DataFrames.
153
+ """Converts AGS 4 data to a dictionary of pandas DataFrames.
156
154
 
157
155
  Args:
158
- ags_data (str): The AGS 4 data as a string.
156
+ ags4_data (str): The AGS 4 data as a string.
159
157
 
160
158
  Returns:
161
159
  Dict[str, pd.DataFrame]: A dictionary of pandas DataFrames, where each key represents a group name from AGS 4 data,
@@ -1,4 +1,4 @@
1
- """Transforms, i.e. maps, AGS data to Bedrock's schema"""
1
+ """Transforms, i.e. maps, AGS data to Bedrock's schema."""
2
2
 
3
3
  from typing import Dict
4
4
 
@@ -12,9 +12,43 @@ from bedrock_ge.gi.schemas import BaseInSitu, BaseLocation, BaseSample, Project
12
12
  from bedrock_ge.gi.validate import check_foreign_key
13
13
 
14
14
 
15
+ # What this function really does, is add the CRS and Bedrock columns:
16
+ # - `project_uid`
17
+ # - `location_uid`
18
+ # - `sample_id`
19
+ # - `sample_uid`
20
+ # - `depth_to_`
21
+ # There really isn't any mapping going on here...
22
+ # TODO: Make sure that the name of the function and docstrings reflect this.
15
23
  def ags3_db_to_no_gis_brgi_db(
16
24
  ags3_db: Dict[str, pd.DataFrame], crs: CRS
17
25
  ) -> Dict[str, pd.DataFrame]:
26
+ """Maps a database with GI data from a single AGS 3 file to a database with Bedrock's schema.
27
+
28
+ This function converts an AGS 3 formatted geotechnical database into Bedrock's
29
+ internal database format, maintaining data relationships and structure. It handles
30
+ various types of geotechnical data including project information, locations,
31
+ samples, lab tests, and in-situ measurements.
32
+
33
+ The mapping process:
34
+ 1. Project Data: Converts AGS 3 'PROJ' group to Bedrock's 'Project' table
35
+ 2. Location Data: Converts AGS 3 'HOLE' group to Bedrock's 'Location' table
36
+ 3. Sample Data: Converts AGS 3 'SAMP' group to Bedrock's 'Sample' table
37
+ 4. Other Data: Handles lab tests, in-situ measurements, and miscellaneous tables
38
+
39
+ Args:
40
+ ags3_db (Dict[str, pd.DataFrame]): A dictionary containing AGS 3 data tables,
41
+ where keys are table names and values are pandas DataFrames.
42
+ crs (CRS): Coordinate Reference System for the project data.
43
+
44
+ Returns:
45
+ Dict[str, pd.DataFrame]: A dictionary containing Bedrock GI database tables,
46
+ where keys are table names and values are transformed pandas DataFrames.
47
+
48
+ Note:
49
+ The function creates a copy of the input database to avoid modifying the original data.
50
+ It performs foreign key checks to maintain data integrity during the mapping.
51
+ """
18
52
  # Make sure that the AGS 3 database is not changed outside this function.
19
53
  ags3_db = ags3_db.copy()
20
54
 
@@ -134,7 +168,7 @@ def ags3_samp_to_brgi_sample(
134
168
  def ags3_in_situ_to_brgi_in_situ(
135
169
  group_name: str, ags3_in_situ: pd.DataFrame, project_uid: str
136
170
  ) -> DataFrame[BaseInSitu]:
137
- """Transform, i.e. map, AGS 3 in-situ measurement data to Bedrock's in-situ data schema.
171
+ """Maps AGS 3 in-situ measurement data to Bedrock's in-situ data schema.
138
172
 
139
173
  Args:
140
174
  group_name (str): The AGS 3 group name.
@@ -5,7 +5,7 @@ def check_ags_proj_group(ags_proj: pd.DataFrame) -> bool:
5
5
  """Checks if the AGS 3 or AGS 4 PROJ group is correct.
6
6
 
7
7
  Args:
8
- proj_df (pd.DataFrame): The DataFrame with the PROJ group.
8
+ ags_proj (pd.DataFrame): The DataFrame with the PROJ group.
9
9
 
10
10
  Raises:
11
11
  ValueError: If AGS 3 of AGS 4 PROJ group is not correct.
@@ -13,7 +13,6 @@ def check_ags_proj_group(ags_proj: pd.DataFrame) -> bool:
13
13
  Returns:
14
14
  bool: Returns True if the AGS 3 or AGS 4 PROJ group is correct.
15
15
  """
16
-
17
16
  if len(ags_proj) != 1:
18
17
  raise ValueError("The PROJ group must contain exactly one row.")
19
18
 
@@ -8,11 +8,12 @@ def concatenate_databases(
8
8
  db1: Dict[str, Union[pd.DataFrame, gpd.GeoDataFrame]],
9
9
  db2: Dict[str, Union[pd.DataFrame, gpd.GeoDataFrame]],
10
10
  ) -> Dict[str, pd.DataFrame]:
11
- """
12
- Concatenate two dictionaries of pandas dataframes into one dict of dfs.
11
+ """Concatenates two dictionaries of DataFrames into one dict of DataFrames.
13
12
 
14
- The function concatenates the pandas dataframes of the second dict of dfs to the first dict of df for the keys that they have in common.
15
- Keys that don't occur in either of the dict of dfs need to end up in the final dict of dfs.
13
+ The function concatenates the pandas DataFrames of the second dict of
14
+ DataFrames to the first dict of DataFrames for the keys they have in common.
15
+ Keys that are unique to either dictionary will be included in the final
16
+ concatenated dictionary.
16
17
 
17
18
  Args:
18
19
  db1 (Dict[str, pd.DataFrame]): A dictionary of pandas DataFrames, i.e. a database.
@@ -21,7 +22,6 @@ def concatenate_databases(
21
22
  Returns:
22
23
  dict: A dictionary of concatenated pandas DataFrames.
23
24
  """
24
-
25
25
  # Create a new dict to store the concatenated dataframes
26
26
  concatenated_dict = {key: df.dropna(axis=1, how="all") for key, df in db1.items()}
27
27
 
@@ -12,11 +12,41 @@ from shapely.geometry import LineString, Point
12
12
 
13
13
  def calculate_gis_geometry(
14
14
  no_gis_brgi_db: Dict[str, Union[pd.DataFrame, gpd.GeoDataFrame]],
15
+ verbose: bool = True,
15
16
  ) -> Dict[str, gpd.GeoDataFrame]:
17
+ """Calculates GIS geometry for tables in a Bedrock Ground Investigation database.
18
+
19
+ This function processes a dictionary of DataFrames containing Ground Investigation (GI) data,
20
+ adding appropriate GIS geometry to each table. It handles both 2D and 3D geometries,
21
+ including vertical boreholes and sampling locations.
22
+
23
+ Args:
24
+ no_gis_brgi_db (Dict[str, Union[pd.DataFrame, gpd.GeoDataFrame]]): Dictionary containing
25
+ the Bedrock GI database tables without GIS geometry. Keys are table names,
26
+ values are either pandas DataFrames or GeoDataFrames.
27
+ verbose (bool, optional): Whether to print progress information. Defaults to True.
28
+
29
+ Returns:
30
+ Dict[str, gpd.GeoDataFrame]: Dictionary containing the Bedrock GI database tables
31
+ with added GIS geometry. All tables are converted to GeoDataFrames with
32
+ appropriate CRS and geometry columns.
33
+
34
+ Raises:
35
+ ValueError: If the projects in the database use different Coordinate Reference Systems (CRS).
36
+
37
+ Note:
38
+ The function performs the following operations:
39
+ 1. Verifies all projects use the same CRS
40
+ 2. Calculates GIS geometry for the 'Location' table
41
+ 3. Creates a 'LonLatHeight' table for 2D visualization
42
+ 4. Processes 'Sample' table if present
43
+ 5. Processes all tables starting with "InSitu_"
44
+ """
16
45
  # Make sure that the Bedrock database is not changed outside this function.
17
46
  brgi_db = no_gis_brgi_db.copy()
18
47
 
19
- print("Calculating GIS geometry for the Bedrock GI database tables...")
48
+ if verbose:
49
+ print("Calculating GIS geometry for the Bedrock GI database tables...")
20
50
 
21
51
  # Check if all projects have the same CRS
22
52
  if not brgi_db["Project"]["crs_wkt"].nunique() == 1:
@@ -28,7 +58,8 @@ def calculate_gis_geometry(
28
58
  crs = CRS.from_wkt(brgi_db["Project"]["crs_wkt"].iloc[0])
29
59
 
30
60
  # Calculate GIS geometry for the 'Location' table
31
- print("Calculating GIS geometry for the Bedrock GI 'Location' table...")
61
+ if verbose:
62
+ print("Calculating GIS geometry for the Bedrock GI 'Location' table...")
32
63
  brgi_db["Location"] = calculate_location_gis_geometry(brgi_db["Location"], crs)
33
64
 
34
65
  # Create the 'LonLatHeight' table.
@@ -36,11 +67,12 @@ def calculate_gis_geometry(
36
67
  # because vertical lines are often very small or completely hidden in 2D.
37
68
  # This table only contains the 3D of the GI locations at ground level,
38
69
  # in WGS84 (Longitude, Latitude, Height) coordinates.
39
- print(
40
- "Creating 'LonLatHeight' table with GI locations in WGS84 geodetic coordinates...",
41
- " WGS84 geodetic coordinates: (Longitude, Latitude, Ground Level Ellipsoidal Height)",
42
- sep="\n",
43
- )
70
+ if verbose:
71
+ print(
72
+ "Creating 'LonLatHeight' table with GI locations in WGS84 geodetic coordinates...",
73
+ " WGS84 geodetic coordinates: (Longitude, Latitude, Ground Level Ellipsoidal Height)",
74
+ sep="\n",
75
+ )
44
76
  brgi_db["LonLatHeight"] = create_lon_lat_height_table(brgi_db["Location"], crs)
45
77
 
46
78
  # Create GIS geometry for tables that have In-Situ GIS geometry.
@@ -48,16 +80,18 @@ def calculate_gis_geometry(
48
80
  # These tables are children of the Location table,
49
81
  # i.e. have the 'Location' table as the parent table.
50
82
  if "Sample" in brgi_db.keys():
51
- print("Calculating GIS geometry for the Bedrock GI 'Sample' table...")
83
+ if verbose:
84
+ print("Calculating GIS geometry for the Bedrock GI 'Sample' table...")
52
85
  brgi_db["Sample"] = calculate_in_situ_gis_geometry(
53
86
  brgi_db["Sample"], brgi_db["Location"], crs
54
87
  )
55
88
 
56
89
  for table_name, table in brgi_db.items():
57
90
  if table_name.startswith("InSitu_"):
58
- print(
59
- f"Calculating GIS geometry for the Bedrock GI '{table_name}' table..."
60
- )
91
+ if verbose:
92
+ print(
93
+ f"Calculating GIS geometry for the Bedrock GI '{table_name}' table..."
94
+ )
61
95
  brgi_db[table_name] = calculate_in_situ_gis_geometry(
62
96
  table, brgi_db["Location"], crs
63
97
  )
@@ -68,20 +102,19 @@ def calculate_gis_geometry(
68
102
  def calculate_location_gis_geometry(
69
103
  brgi_location: Union[pd.DataFrame, gpd.GeoDataFrame], crs: CRS
70
104
  ) -> gpd.GeoDataFrame:
71
- """
72
- Calculate GIS geometry for a set of Ground Investigation locations.
105
+ """Calculates GIS geometry for a set of Ground Investigation locations.
73
106
 
74
107
  Args:
75
108
  brgi_location (Union[pd.DataFrame, gpd.GeoDataFrame]): The GI locations to calculate GIS geometry for.
76
109
  crs (pyproj.CRS): The Coordinate Reference System (CRS) to use for the GIS geometry.
77
110
 
78
111
  Returns:
79
- gpd.GeoDataFrame: The GIS geometry for the given GI locations, with *additional* columns:
80
- longitude: The longitude of the location in the WGS84 CRS.
81
- latitude: The latitude of the location in the WGS84 CRS.
82
- wgs84_ground_level_height: The height of the ground level of the location in the WGS84 CRS.
83
- elevation_at_base: The elevation at the base of the location.
84
- geometry: The GIS geometry of the location.
112
+ gpd.GeoDataFrame: The GIS geometry for the given GI locations, with additional columns:
113
+ - longitude: The longitude of the location in the WGS84 CRS.
114
+ - latitude: The latitude of the location in the WGS84 CRS.
115
+ - wgs84_ground_level_height: The height of the ground level of the location in the WGS84 CRS.
116
+ - elevation_at_base: The elevation at the base of the location.
117
+ - geometry: The GIS geometry of the location.
85
118
  """
86
119
  # Calculate Elevation at base of GI location
87
120
  brgi_location["elevation_at_base"] = (
@@ -123,8 +156,7 @@ def calculate_location_gis_geometry(
123
156
  def calculate_wgs84_coordinates(
124
157
  from_crs: CRS, easting: float, northing: float, elevation: Union[float, None] = None
125
158
  ) -> Tuple:
126
- """Transform coordinates from an arbitrary Coordinate Reference System (CRS) to
127
- the WGS84 CRS, which is the standard for geodetic coordinates.
159
+ """Transforms coordinates from an arbitrary Coordinate Reference System (CRS) to the WGS84 CRS, which is the standard for geodetic coordinates.
128
160
 
129
161
  Args:
130
162
  from_crs (pyproj.CRS): The pyproj.CRS object of the CRS to transform from.
@@ -151,7 +183,7 @@ def calculate_wgs84_coordinates(
151
183
  def create_lon_lat_height_table(
152
184
  brgi_location: gpd.GeoDataFrame, crs: CRS
153
185
  ) -> gpd.GeoDataFrame:
154
- """Create a GeoDataFrame with GI locations in WGS84 (lon, lat, height) coordinates.
186
+ """Creates a GeoDataFrame with GI locations in WGS84 (lon, lat, height) coordinates.
155
187
 
156
188
  The 'LonLatHeight' table makes it easier to visualize the GIS geometry on 2D maps,
157
189
  because vertical lines are often very small or completely hidden in 2D. This table
@@ -190,6 +222,19 @@ def calculate_in_situ_gis_geometry(
190
222
  brgi_location: Union[pd.DataFrame, gpd.GeoDataFrame],
191
223
  crs: CRS,
192
224
  ) -> gpd.GeoDataFrame:
225
+ """Calculates GIS geometry for a set of Ground Investigation in-situ data.
226
+
227
+ Args:
228
+ brgi_in_situ (Union[pd.DataFrame, gpd.GeoDataFrame]): The in-situ data to calculate GIS geometry for.
229
+ brgi_location (Union[pd.DataFrame, gpd.GeoDataFrame]): The location data to merge with the in-situ data.
230
+ crs (CRS): The Coordinate Reference System of the in-situ data.
231
+
232
+ Returns:
233
+ gpd.GeoDataFrame: The GIS geometry for the given in-situ data, with additional columns:
234
+ - elevation_at_top: The elevation at the top of the in-situ data.
235
+ - elevation_at_base: The elevation at the base of the in-situ data.
236
+ - geometry: The GIS geometry of the in-situ data.
237
+ """
193
238
  location_child = brgi_in_situ.copy()
194
239
 
195
240
  # Merge the location data into the in-situ data to get the location coordinates
bedrock_ge/gi/validate.py CHANGED
@@ -14,7 +14,38 @@ from bedrock_ge.gi.schemas import (
14
14
  )
15
15
 
16
16
 
17
- def check_brgi_database(brgi_db: Dict):
17
+ # TODO: rename to check_brgi_geodb
18
+ # TODO: make this check actually work...
19
+ def check_brgi_database(brgi_db: Dict[str, Union[pd.DataFrame, gpd.GeoDataFrame]]):
20
+ """Validates the structure and relationships of a 'Bedrock Ground Investigation' (BRGI) database (which is a dictionary of DataFrames).
21
+
22
+ This function checks that all tables in the BRGI database conform to their respective schemas
23
+ and that all foreign key relationships are properly maintained. It validates the following tables:
24
+ - Project
25
+ - Location
26
+ - Sample
27
+ - InSitu_TESTX
28
+ - Lab_TESTY (not yet implemented)
29
+
30
+ Args:
31
+ brgi_db (Dict[str, Union[pd.DataFrame, gpd.GeoDataFrame]]): A dictionary
32
+ containing the BRGI database tables, where keys are table names and
33
+ values are the corresponding data tables (DataFrame or GeoDataFrame).
34
+
35
+ Returns:
36
+ bool: True if all tables are valid and relationships are properly maintained.
37
+
38
+ Example:
39
+ ```python
40
+ brgi_db = {
41
+ "Project": project_df,
42
+ "Location": location_gdf,
43
+ "Sample": sample_gdf,
44
+ "InSitu_ISPT": in_situ_ispt_gdf,
45
+ }
46
+ check_brgi_database(brgi_db)
47
+ ```
48
+ """
18
49
  for table_name, table in brgi_db.items():
19
50
  if table_name == "Project":
20
51
  Project.validate(table)
@@ -28,6 +59,9 @@ def check_brgi_database(brgi_db: Dict):
28
59
  check_foreign_key("project_uid", brgi_db["Project"], table)
29
60
  check_foreign_key("location_uid", brgi_db["Location"], table)
30
61
  print("'Sample' table aligns with Bedrock's 'Sample' table schema.")
62
+ # ! JG is pretty sure that this doesn't work
63
+ # ! The line below should be:
64
+ # ! elif table_name.startswith("InSitu_"):
31
65
  elif table_name == "InSitu":
32
66
  InSitu.validate(table)
33
67
  check_foreign_key("project_uid", brgi_db["Project"], table)
@@ -43,7 +77,39 @@ def check_brgi_database(brgi_db: Dict):
43
77
  return True
44
78
 
45
79
 
46
- def check_no_gis_brgi_database(brgi_db: Dict):
80
+ # TODO: rename to check_brgi_db
81
+ def check_no_gis_brgi_database(
82
+ brgi_db: Dict[str, Union[pd.DataFrame, gpd.GeoDataFrame]],
83
+ ):
84
+ """Validates the structure and relationships of a 'Bedrock Ground Investigation' (BGI) database without GIS geometry.
85
+
86
+ This function performs the same validation as `check_brgi_database` but uses schemas
87
+ that don't require GIS geometry. It validates the following tables:
88
+ - Project (never has GIS geometry)
89
+ - Location (without GIS geometry)
90
+ - Sample (without GIS geometry)
91
+ - InSitu_TESTX (without GIS geometry)
92
+ - Lab_TESTY (not yet implemented)
93
+
94
+ Args:
95
+ brgi_db (Dict[str, Union[pd.DataFrame, gpd.GeoDataFrame]]): A dictionary
96
+ containing the Bedrock GI database tables, where keys are table names
97
+ and values are the corresponding data tables (DataFrame or GeoDataFrame).
98
+
99
+ Returns:
100
+ bool: True if all tables are valid and relationships are properly maintained.
101
+
102
+ Example:
103
+ ```python
104
+ brgi_db = {
105
+ "Project": projects_df,
106
+ "Location": locations_df,
107
+ "Sample": samples_df,
108
+ "InSitu_measurements": insitu_df,
109
+ }
110
+ check_no_gis_brgi_database(brgi_db)
111
+ ```
112
+ """
47
113
  for table_name, table in brgi_db.items():
48
114
  if table_name == "Project":
49
115
  Project.validate(table)
@@ -81,26 +147,26 @@ def check_foreign_key(
81
147
  parent_table: Union[pd.DataFrame, gpd.GeoDataFrame],
82
148
  table_with_foreign_key: Union[pd.DataFrame, gpd.GeoDataFrame],
83
149
  ) -> bool:
84
- """
85
- Checks if a foreign key in a table exists in the parent table.
150
+ """Validates referential integrity between two tables by checking foreign key relationships.
86
151
 
87
- Foreign keys describe the relationship between tables in a relational database.
88
- For example, all GI Locations belong to a project.
89
- All GI Locations are related to a project with the project_uid (Project Unique IDentifier).
90
- The project_uid is the foreign key in the Location table.
91
- This implies that the project_uid in the foreign key in the Location table must exist in the Project parent table.
92
- That is what this function checks.
152
+ This function ensures that all foreign key values in a child table exist in the corresponding
153
+ parent table, maintaining data integrity in the GIS database.
93
154
 
94
155
  Args:
95
- foreign_key (str): The name of the column of the foreign key.
96
- parent_table (Union[pd.DataFrame, gpd.GeoDataFrame]): The parent table.
97
- table_with_foreign_key (Union[pd.DataFrame, gpd.GeoDataFrame]): The table with the foreign key.
156
+ foreign_key (str): The name of the column that serves as the foreign key.
157
+ parent_table (Union[pd.DataFrame, gpd.GeoDataFrame]): The parent table containing the primary keys.
158
+ table_with_foreign_key (Union[pd.DataFrame, gpd.GeoDataFrame]): The child table containing the foreign keys.
159
+
160
+ Returns:
161
+ bool: True if all foreign keys exist in the parent table.
98
162
 
99
163
  Raises:
100
- ValueError: If the table with the foreign key contains foreign keys that don't occur in the parent table.
164
+ ValueError: If any foreign key values in the child table do not exist in the parent table.
101
165
 
102
- Returns:
103
- bool: True if the foreign keys all exist in the parent table.
166
+ Example:
167
+ ```python
168
+ check_foreign_key("project_uid", projects_df, locations_df)
169
+ ```
104
170
  """
105
171
  # Get the foreign keys that are missing in the parent group
106
172
  missing_foreign_keys = table_with_foreign_key[
bedrock_ge/gi/write.py CHANGED
@@ -9,19 +9,20 @@ def write_gi_db_to_gpkg(
9
9
  brgi_db: Dict[str, gpd.GeoDataFrame],
10
10
  gpkg_path: Union[str, Path],
11
11
  ) -> None:
12
- """
13
- Write a database, i.e. a dictionary of DataFrames, with Bedrock Ground Investigation data to a GeoPackage file.
12
+ """Writes a database with Bedrock Ground Investigation data to a GeoPackage file.
14
13
 
15
- Each DataFrame will be saved in a separate table named after the keys of the dictionary.
14
+ Writes a dictionary of DataFrames containing Bedrock Ground Investigation data to a
15
+ [GeoPackage file](https://www.geopackage.org/). Each DataFrame will be saved in a
16
+ separate table named by the keys of the dictionary.
16
17
 
17
18
  Args:
18
- brgi_dfs (dict): A dictionary where keys are brgi table names and values are DataFrames with brgi data.
19
+ brgi_db (dict): A dictionary where keys are brgi table names and values are DataFrames
20
+ with brgi data.
19
21
  gpkg_path (str): The name of the output GeoPackage file.
20
22
 
21
23
  Returns:
22
- None: This function does not return any value. It writes the DataFrames to a GeoPackage file.
24
+ None
23
25
  """
24
-
25
26
  # Create a GeoDataFrame from the dictionary of DataFrames
26
27
  for sheet_name, brgi_table in brgi_db.items():
27
28
  sanitized_table_name = sanitize_table_name(sheet_name)
@@ -41,20 +42,19 @@ def write_gi_db_to_excel(
41
42
  gi_db: Dict[str, Union[pd.DataFrame, gpd.GeoDataFrame]],
42
43
  excel_path: Union[str, Path],
43
44
  ) -> None:
44
- """
45
- Write a database, i.e. a dictionary of DataFrames, with Ground Investigation data to an Excel file.
45
+ """Writes a database with Ground Investigation data to an Excel file.
46
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.
47
+ Each DataFrame in the database dictionary will be saved in a separate Excel sheet named
48
+ after the dictionary keys. This function can be used on any GI database, whether in
49
+ AGS, Bedrock, or another format.
49
50
 
50
51
  Args:
51
52
  gi_dfs (dict): A dictionary where keys are GI table names and values are DataFrames with GI data.
52
53
  excel_path (str): The name of the output Excel file.
53
54
 
54
55
  Returns:
55
- None: This function does not return any value. It writes the DataFrames to an Excel file.
56
+ None
56
57
  """
57
-
58
58
  # Create an Excel writer object
59
59
  with pd.ExcelWriter(excel_path, engine="openpyxl") as writer:
60
60
  for sheet_name, df in gi_db.items():
@@ -65,16 +65,18 @@ def write_gi_db_to_excel(
65
65
  print(f"Ground Investigation data has been written to '{excel_path}'.")
66
66
 
67
67
 
68
+ # TODO: Make the 31 character table name length truncation a separate function. Only necessary for Excel.
68
69
  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.
70
+ """Replaces invalid characters and spaces in GI table names with underscores and truncates to 31 characters.
71
+
72
+ Makes table names consistent with SQL, GeoPackage and Excel naming conventions by
73
+ replacing invalid characters and spaces with underscores.
72
74
 
73
75
  Args:
74
76
  sheet_name (str): The original sheet name.
75
77
 
76
78
  Returns:
77
- str: A sanitized sheet name with invalid characters and spaces replaced.
79
+ sanitized_name: A sanitized sheet name with invalid characters and spaces replaced.
78
80
  """
79
81
  # Trim to a maximum length of 31 characters
80
82
  trimmed_name = sheet_name.strip()[:31]
@@ -98,6 +100,7 @@ def sanitize_table_name(sheet_name):
98
100
  )
99
101
 
100
102
  # Ensure name isn't empty after sanitization
103
+ # ! "Table1" doesn't make a lot of sense?!? It could be that there are more than 1 table without a name...
101
104
  if not sanitized_name:
102
105
  sanitized_name = "Table1"
103
106
  print("The table name was completely invalid or empty. Replaced with 'Table1'.")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bedrock-ge
3
- Version: 0.2.2
3
+ Version: 0.2.3
4
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
@@ -36,19 +36,19 @@ Description-Content-Type: text/markdown
36
36
  <img src="https://bedrock.engineer/public/Bedrock_TextRight.png" alt="Bedrock logo" width="75%"/>
37
37
  </p>
38
38
 
39
- <h3 align="center">Bedrock, the Open Source Foundation for Ground Investigation Data</h3>
39
+ <h3 align="center">Bedrock, the Open Source Foundation for Geotechnical Engineering</h3>
40
40
 
41
41
  ---
42
42
 
43
43
  📃 **Documentation:** <https://bedrock.engineer/docs>
44
44
 
45
- 🖥️ **Source Code:** <https://github.com/bedrock-gi/bedrock-gi>
45
+ 🖥️ **Source Code:** <https://github.com/bedrock-engineer/bedrock-ge>
46
46
 
47
- 🐍 **`bedrock-gi` on PyPI:** <https://pypi.org/project/bedrock-gi/>
47
+ 🐍 **`bedrock-ge` on PyPI:** <https://pypi.org/project/bedrock-ge/>
48
48
 
49
49
  🌐 **Website:** <https://bedrock.engineer/>
50
50
 
51
- 🔗 **LinkedIn:** <https://www.linkedin.com/company/bedrock-gi>
51
+ 🔗 **LinkedIn:** <https://www.linkedin.com/company/bedrock-engineer>
52
52
 
53
53
  ---
54
54
 
@@ -66,13 +66,13 @@ Description-Content-Type: text/markdown
66
66
  | GeoJSON | ✅ | ✅ |
67
67
 
68
68
  What do you need? [DIGGS](https://diggsml.org/)? [NADAG](https://www.ngu.no/geologisk-kartlegging/om-nadag-nasjonal-database-grunnundersokelser)? [GEF](https://publicwiki.deltares.nl/display/STREAM/Dutch+National+GEF+Standards)? Something else?
69
- Let us know by creating an [issue](https://github.com/bedrock-gi/bedrock-gi/issues) or starting a [discussion](https://github.com/orgs/bedrock-gi/discussions) 💭
69
+ Let us know by creating an [issue](https://github.com/bedrock-engineer/bedrock-ge/issues) or starting a [discussion](https://github.com/orgs/bedrock-engineer/discussions) 💭
70
70
 
71
- Also, if you have a project with publicly available GI data, please share that in a [discussion](https://github.com/orgs/bedrock-gi/discussions), such that we can create a tutorial from it 🤩
71
+ Also, if you have a project with publicly available GI data, please share that in a [discussion](https://github.com/orgs/bedrock-engineer/discussions), such that we can create a tutorial from it 🤩
72
72
 
73
73
  ### ✅ Validate your GI data
74
74
 
75
- `bedrock-gi` comes with data validation to make sure that you can combine Ground Investigation data from multiple files into a single GIS database with consistent relationships between GI locations, samples, in-situ measurements and lab tests.
75
+ `bedrock-ge` comes with data validation to make sure that you can combine Ground Investigation data from multiple files into a single GIS database with consistent relationships between GI locations, samples, in-situ measurements and lab tests.
76
76
 
77
77
  This data validation mechanism (based on [`pandera`](https://pandera.readthedocs.io/en/stable/)) is easily extensible, giving you the power to add your own data validation criteria 💪
78
78
 
@@ -98,7 +98,7 @@ Moreover, your GI data becomes available in all the software that [Speckle has c
98
98
 
99
99
  ### 🔓 Free and Open Source Software
100
100
 
101
- Free and Open Source Software (FOSS) gives you full access to the code, which means you can customize `bedrock-gi` to integrate with other tools and fit your workflows & project needs.
101
+ Free and Open Source Software (FOSS) gives you full access to the code, which means you can customize `bedrock-ge` to integrate with other tools and fit your workflows & project needs.
102
102
 
103
103
  As the name implies, FOSS is free to use, so you're not tied to expensive software licenses or locked into a specific software vendor ⛓️‍💥
104
104
 
@@ -148,10 +148,10 @@ This relational database ([linked tables](https://en.wikipedia.org/wiki/Relation
148
148
 
149
149
  ## ⬇️ Installation
150
150
 
151
- In case you're using `uv`, you can add `bedrock-gi` to your Python project and install it in your project's virtual environment by running:
151
+ In case you're using `uv`, you can add `bedrock-ge` to your Python project and install it in your project's virtual environment by running:
152
152
 
153
153
  ```bash
154
- uv add bedrock-gi
154
+ uv add bedrock-ge
155
155
  ```
156
156
 
157
157
  I would highly recommend anyone to start using [`uv`](https://docs.astral.sh/uv/) (Unified Virtual Environment Manager) if you're not already doing so. Some of the advantages (Source: [`uv`](https://docs.astral.sh/uv/)):
@@ -161,10 +161,10 @@ I would highly recommend anyone to start using [`uv`](https://docs.astral.sh/uv/
161
161
  - 🗂️ `uv` provides [comprehensive project management](https://docs.astral.sh/uv/#project-management), with a [universal lockfile](https://docs.astral.sh/uv/concepts/projects/#project-lockfile). This means no more headaches about virtual environments (or having to explain what on earth a virtual env is), or people running different versions of Python or Python packages on the same project, causing errors and other problems.
162
162
  - In short, 🚀 `uv` is a single tool to replace `pip`, `pip-tools`, `pipx`, `poetry`, `pyenv`, `virtualenv`, `conda` and more...
163
163
 
164
- It's of course also possible to install `bedrock-gi` from [PyPI](https://pypi.org/project/bedrock-gi/) (Python Packaging Index) using `pip`:
164
+ It's of course also possible to install `bedrock-ge` from [PyPI](https://pypi.org/project/bedrock-ge/) (Python Packaging Index) using `pip`:
165
165
 
166
166
  ```bash
167
- pip install bedrock-gi
167
+ pip install bedrock-ge
168
168
  ```
169
169
 
170
170
  ## 💭 Feedback
@@ -173,8 +173,8 @@ Got some feedback, a great idea, running into problems when working with Bedrock
173
173
 
174
174
  Please feel free to:
175
175
 
176
- 1. open an issue for feature requests or bug reports: [`bedrock-gi` issues](https://github.com/bedrock-gi/bedrock-gi/issues),
177
- 2. start a discussion in this GitHub repo: [Bedrock discussions](https://github.com/orgs/bedrock-gi/discussions),
176
+ 1. open an issue for feature requests or bug reports: [`bedrock-ge` issues](https://github.com/bedrock-engineer/bedrock-ge/issues),
177
+ 2. start a discussion in this GitHub repo: [Bedrock discussions](https://github.com/orgs/bedrock-engineer/discussions),
178
178
  3. or start a discussion on the Speckle community forum if that's more appropriate: [Speckle community forum](https://speckle.community/)
179
179
 
180
180
  All feedback and engagement with the Bedrock community is welcome 🤗
@@ -189,7 +189,7 @@ Contributing isn't just about writing code:
189
189
 
190
190
  - Use Bedrock and provide [feedback](#-feedback) 🪲
191
191
  - Share how you use Bedrock 🏗️
192
- - Help each other out, e.g. by replying to questions in the [discussions](https://github.com/orgs/bedrock-gi/discussions) or [`bedrock-gi` issues](https://github.com/bedrock-gi/bedrock-gi/issues) 🤝
192
+ - Help each other out, e.g. by replying to questions in the [discussions](https://github.com/orgs/bedrock-engineer/discussions) or [`bedrock-ge` issues](https://github.com/bedrock-engineer/bedrock-ge/issues) 🤝
193
193
  - Spread the word about Bedrock 🤩
194
194
  - Documentation and tutorials 📃
195
195
  - Most pages on the [bedrock.engineer](https://bedrock.engineer/) website can be edited, so if you see a spelling mistake or have a suggestion on how to explain something better, please smash that button! 🖱️💥
@@ -211,7 +211,7 @@ If you want your ground investigation data to go into a GIS database, all GIS ge
211
211
 
212
212
  Therefore, if you are dealing with GI data collected using different projected CRS's, you'll have to convert the Easting, Northing, z-coordinates to global longitude, latitude, ellipsoidal height coordinates in a geodetic CRS. ([Further reading](https://clover-animantarx-a3a.notion.site/Geomatics-36dfece2dece4358b44c44d08c9cded6))
213
213
 
214
- Please start a [discussion](https://github.com/orgs/bedrock-gi/discussions) or create an issue if want to be able to put data that were collected in different projected CRS's into a single GIS database. This is pretty easy with [`geopandas`](https://geopandas.org/en/stable/) / [`pyproj`](https://pyproj4.github.io/pyproj/stable/) transformations, but hasn't been necessary yet.
214
+ Please start a [discussion](https://github.com/orgs/bedrock-engineer/discussions) or create an issue if want to be able to put data that were collected in different projected CRS's into a single GIS database. This is pretty easy with [`geopandas`](https://geopandas.org/en/stable/) / [`pyproj`](https://pyproj4.github.io/pyproj/stable/) transformations, but hasn't been necessary yet.
215
215
 
216
216
  ## ✍️ Author
217
217
 
@@ -0,0 +1,21 @@
1
+ bedrock_ge/__init__.py,sha256=r2ubK-fPZKVKQX5ggtX8Vx3YWk9c-bDNE1FmKYxUNCE,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/brgi-schema.json,sha256=XaumYqouiflu4Nc8ChyFSHpmpJW4YPG0hsyeSxkuIWQ,850
5
+ bedrock_ge/gi/concatenate.py,sha256=2He9us_q5MF3DbXPIK50-VHtWqkiBNyM63e0vwId2Hc,1480
6
+ bedrock_ge/gi/gis_geometry.py,sha256=NxJnuu9xfhlYO5pblynbZQnVYFIQoBx5xnBepQoZG3c,11570
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=0qGTtwytJQbYnRoXa2dj7clsyVPhB9AYPDHVIrK83qc,7069
10
+ bedrock_ge/gi/write.py,sha256=3-81-CydjO0BkLNzckGKz1f4G5v9uNWFKRvjZ183PFc,4110
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=zb4XHzPKEr7GQ4EeKVRPmy3-v7LVr-Cihog5HtruszE,7077
15
+ bedrock_ge/gi/ags/schemas.py,sha256=y36n9SCKqFfoIQ_7-MTEdfArA5vAqZdRpY3wC4fdjy4,7451
16
+ bedrock_ge/gi/ags/transform.py,sha256=BB0H_pMKiXF6Px4K6RlMwlQ0c3GXcuSBZFHjyt5QrhM,9984
17
+ bedrock_ge/gi/ags/validate.py,sha256=ZfBS7AP_CTguLQCbGeyy4Krz32th2yCmtdG9rvX0MOU,703
18
+ bedrock_ge-0.2.3.dist-info/METADATA,sha256=XMO0khsCbGlI1WDso2ITHsJSBgIHtHBZsHrBg-zPMvk,14376
19
+ bedrock_ge-0.2.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
20
+ bedrock_ge-0.2.3.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
21
+ bedrock_ge-0.2.3.dist-info/RECORD,,
@@ -1,21 +0,0 @@
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,,