bedrock-ge 0.2.2__py3-none-any.whl → 0.2.4__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.4"
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.
@@ -19,7 +18,7 @@ def ags_to_dfs(ags_data: str) -> Dict[str, pd.DataFrame]:
19
18
 
20
19
  Returns:
21
20
  Dict[str, pd.DataFrame]]: A dictionary where keys represent AGS group
22
- names with corresponding DataFrames for the corresponding group data.
21
+ names with corresponding DataFrames for the corresponding group data.
23
22
  """
24
23
  # Process each line to find the AGS version and delegate parsing
25
24
  for line in ags_data.splitlines():
@@ -52,16 +51,16 @@ 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
- Dict[str, pd.DataFrame]: A dictionary of pandas DataFrames, where each key represents a group name from AGS 3 data,
62
- and the corresponding value is a pandas DataFrame containing the data for that group.
60
+ Dict[str, pd.DataFrame]: A dictionary of pandas DataFrames, where each key
61
+ represents a group name from AGS 3 data, and the corresponding value is a
62
+ pandas DataFrame containing the data for that group.
63
63
  """
64
-
65
64
  # Initialize dictionary and variables used in the AGS 3 read loop
66
65
  ags3_dfs = {}
67
66
  line_type = "line_0"
@@ -152,14 +151,15 @@ def ags3_to_dfs(ags3_data: str) -> Dict[str, pd.DataFrame]:
152
151
 
153
152
 
154
153
  def ags4_to_dfs(ags4_data: str) -> Dict[str, pd.DataFrame]:
155
- """Convert AGS 4 data to a dictionary of pandas DataFrames.
154
+ """Converts AGS 4 data to a dictionary of pandas DataFrames.
156
155
 
157
156
  Args:
158
- ags_data (str): The AGS 4 data as a string.
157
+ ags4_data (str): The AGS 4 data as a string.
159
158
 
160
159
  Returns:
161
- Dict[str, pd.DataFrame]: A dictionary of pandas DataFrames, where each key represents a group name from AGS 4 data,
162
- and the corresponding value is a pandas DataFrame containing the data for that group.
160
+ Dict[str, pd.DataFrame]: A dictionary of pandas DataFrames, where each key
161
+ represents a group name from AGS 4 data, and the corresponding value is a
162
+ pandas DataFrame containing the data for that group.
163
163
  """
164
164
  # AGS4.AGS4_to_dataframe accepts the file, not the data string
165
165
  ags4_file = io.StringIO(ags4_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,20 +8,20 @@ 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.
19
20
  db2 (Dict[str, pd.DataFrame]): A dictionary of pandas DataFrames, i.e. a database.
20
21
 
21
22
  Returns:
22
- dict: A dictionary of concatenated pandas DataFrames.
23
+ concatenated_dict (Dict[str, pd.DataFrame]): 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,42 @@ 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
+
40
+ 1. Verifies all projects use the same CRS
41
+ 2. Calculates GIS geometry for the 'Location' table
42
+ 3. Creates a 'LonLatHeight' table for 2D visualization
43
+ 4. Processes 'Sample' table if present
44
+ 5. Processes all tables starting with "InSitu_"
45
+ """
16
46
  # Make sure that the Bedrock database is not changed outside this function.
17
47
  brgi_db = no_gis_brgi_db.copy()
18
48
 
19
- print("Calculating GIS geometry for the Bedrock GI database tables...")
49
+ if verbose:
50
+ print("Calculating GIS geometry for the Bedrock GI database tables...")
20
51
 
21
52
  # Check if all projects have the same CRS
22
53
  if not brgi_db["Project"]["crs_wkt"].nunique() == 1:
@@ -28,7 +59,8 @@ def calculate_gis_geometry(
28
59
  crs = CRS.from_wkt(brgi_db["Project"]["crs_wkt"].iloc[0])
29
60
 
30
61
  # Calculate GIS geometry for the 'Location' table
31
- print("Calculating GIS geometry for the Bedrock GI 'Location' table...")
62
+ if verbose:
63
+ print("Calculating GIS geometry for the Bedrock GI 'Location' table...")
32
64
  brgi_db["Location"] = calculate_location_gis_geometry(brgi_db["Location"], crs)
33
65
 
34
66
  # Create the 'LonLatHeight' table.
@@ -36,11 +68,12 @@ def calculate_gis_geometry(
36
68
  # because vertical lines are often very small or completely hidden in 2D.
37
69
  # This table only contains the 3D of the GI locations at ground level,
38
70
  # 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
- )
71
+ if verbose:
72
+ print(
73
+ "Creating 'LonLatHeight' table with GI locations in WGS84 geodetic coordinates...",
74
+ " WGS84 geodetic coordinates: (Longitude, Latitude, Ground Level Ellipsoidal Height)",
75
+ sep="\n",
76
+ )
44
77
  brgi_db["LonLatHeight"] = create_lon_lat_height_table(brgi_db["Location"], crs)
45
78
 
46
79
  # Create GIS geometry for tables that have In-Situ GIS geometry.
@@ -48,16 +81,18 @@ def calculate_gis_geometry(
48
81
  # These tables are children of the Location table,
49
82
  # i.e. have the 'Location' table as the parent table.
50
83
  if "Sample" in brgi_db.keys():
51
- print("Calculating GIS geometry for the Bedrock GI 'Sample' table...")
84
+ if verbose:
85
+ print("Calculating GIS geometry for the Bedrock GI 'Sample' table...")
52
86
  brgi_db["Sample"] = calculate_in_situ_gis_geometry(
53
87
  brgi_db["Sample"], brgi_db["Location"], crs
54
88
  )
55
89
 
56
90
  for table_name, table in brgi_db.items():
57
91
  if table_name.startswith("InSitu_"):
58
- print(
59
- f"Calculating GIS geometry for the Bedrock GI '{table_name}' table..."
60
- )
92
+ if verbose:
93
+ print(
94
+ f"Calculating GIS geometry for the Bedrock GI '{table_name}' table..."
95
+ )
61
96
  brgi_db[table_name] = calculate_in_situ_gis_geometry(
62
97
  table, brgi_db["Location"], crs
63
98
  )
@@ -68,20 +103,19 @@ def calculate_gis_geometry(
68
103
  def calculate_location_gis_geometry(
69
104
  brgi_location: Union[pd.DataFrame, gpd.GeoDataFrame], crs: CRS
70
105
  ) -> gpd.GeoDataFrame:
71
- """
72
- Calculate GIS geometry for a set of Ground Investigation locations.
106
+ """Calculates GIS geometry for a set of Ground Investigation locations.
73
107
 
74
108
  Args:
75
109
  brgi_location (Union[pd.DataFrame, gpd.GeoDataFrame]): The GI locations to calculate GIS geometry for.
76
110
  crs (pyproj.CRS): The Coordinate Reference System (CRS) to use for the GIS geometry.
77
111
 
78
112
  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.
113
+ gpd.GeoDataFrame: The GIS geometry for the given GI locations, with additional columns:
114
+ - longitude: The longitude of the location in the WGS84 CRS.
115
+ - latitude: The latitude of the location in the WGS84 CRS.
116
+ - wgs84_ground_level_height: The height of the ground level of the location in the WGS84 CRS.
117
+ - elevation_at_base: The elevation at the base of the location.
118
+ - geometry: The GIS geometry of the location.
85
119
  """
86
120
  # Calculate Elevation at base of GI location
87
121
  brgi_location["elevation_at_base"] = (
@@ -122,9 +156,8 @@ def calculate_location_gis_geometry(
122
156
 
123
157
  def calculate_wgs84_coordinates(
124
158
  from_crs: CRS, easting: float, northing: float, elevation: Union[float, None] = None
125
- ) -> Tuple:
126
- """Transform coordinates from an arbitrary Coordinate Reference System (CRS) to
127
- the WGS84 CRS, which is the standard for geodetic coordinates.
159
+ ) -> Tuple[float, float, (float | None)]:
160
+ """Transforms coordinates from an arbitrary Coordinate Reference System (CRS) to the WGS84 CRS, which is the standard for geodetic coordinates.
128
161
 
129
162
  Args:
130
163
  from_crs (pyproj.CRS): The pyproj.CRS object of the CRS to transform from.
@@ -134,9 +167,10 @@ def calculate_wgs84_coordinates(
134
167
  transform. Defaults to None.
135
168
 
136
169
  Returns:
137
- tuple: A tuple containing the longitude, latitude and WGS84 height of the
138
- transformed point, in that order. The height is None if no elevation was
139
- given, or if the provided CRS doesn't have a proper datum defined.
170
+ Tuple[float, float, (float | None)]: A tuple containing the longitude, latitude
171
+ and WGS84 height of the transformed point, in that order.
172
+ The height is None if no elevation was given, or if the provided CRS doesn't
173
+ have a proper datum defined.
140
174
  """
141
175
  transformer = Transformer.from_crs(from_crs, 4326, always_xy=True)
142
176
  if elevation:
@@ -145,13 +179,13 @@ def calculate_wgs84_coordinates(
145
179
  lon, lat = transformer.transform(easting, northing)
146
180
  wgs84_height = None
147
181
 
148
- return lon, lat, wgs84_height
182
+ return (lon, lat, wgs84_height)
149
183
 
150
184
 
151
185
  def create_lon_lat_height_table(
152
186
  brgi_location: gpd.GeoDataFrame, crs: CRS
153
187
  ) -> gpd.GeoDataFrame:
154
- """Create a GeoDataFrame with GI locations in WGS84 (lon, lat, height) coordinates.
188
+ """Creates a GeoDataFrame with GI locations in WGS84 (lon, lat, height) coordinates.
155
189
 
156
190
  The 'LonLatHeight' table makes it easier to visualize the GIS geometry on 2D maps,
157
191
  because vertical lines are often very small or completely hidden in 2D. This table
@@ -165,7 +199,7 @@ def create_lon_lat_height_table(
165
199
  crs (CRS): The Coordinate Reference System of the GI locations.
166
200
 
167
201
  Returns:
168
- GeoDataFrame: The 'LonLatHeight' GeoDataFrame.
202
+ gpd.GeoDataFrame: The 'LonLatHeight' GeoDataFrame.
169
203
  """
170
204
  lon_lat_height = gpd.GeoDataFrame(
171
205
  brgi_location[
@@ -190,6 +224,19 @@ def calculate_in_situ_gis_geometry(
190
224
  brgi_location: Union[pd.DataFrame, gpd.GeoDataFrame],
191
225
  crs: CRS,
192
226
  ) -> gpd.GeoDataFrame:
227
+ """Calculates GIS geometry for a set of Ground Investigation in-situ data.
228
+
229
+ Args:
230
+ brgi_in_situ (Union[pd.DataFrame, gpd.GeoDataFrame]): The in-situ data to calculate GIS geometry for.
231
+ brgi_location (Union[pd.DataFrame, gpd.GeoDataFrame]): The location data to merge with the in-situ data.
232
+ crs (CRS): The Coordinate Reference System of the in-situ data.
233
+
234
+ Returns:
235
+ gpd.GeoDataFrame: The GIS geometry for the given in-situ data, with additional columns:
236
+ - elevation_at_top: The elevation at the top of the in-situ data.
237
+ - elevation_at_base: The elevation at the base of the in-situ data.
238
+ - geometry: The GIS geometry of the in-situ data.
239
+ """
193
240
  location_child = brgi_in_situ.copy()
194
241
 
195
242
  # 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
+ is_valid (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,21 @@ 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[str, Union[pd.DataFrame, gpd.GeoDataFrame]]): A dictionary where
20
+ keys are brgi table names and values are pandas DataFrames or GeoDataFrames
21
+ with brgi data.
19
22
  gpkg_path (str): The name of the output GeoPackage file.
20
23
 
21
24
  Returns:
22
- None: This function does not return any value. It writes the DataFrames to a GeoPackage file.
25
+ None
23
26
  """
24
-
25
27
  # Create a GeoDataFrame from the dictionary of DataFrames
26
28
  for sheet_name, brgi_table in brgi_db.items():
27
29
  sanitized_table_name = sanitize_table_name(sheet_name)
@@ -38,26 +40,27 @@ def write_gi_db_to_gpkg(
38
40
 
39
41
 
40
42
  def write_gi_db_to_excel(
41
- gi_db: Dict[str, Union[pd.DataFrame, gpd.GeoDataFrame]],
43
+ gi_dfs: Dict[str, Union[pd.DataFrame, gpd.GeoDataFrame]],
42
44
  excel_path: Union[str, Path],
43
45
  ) -> None:
44
- """
45
- Write a database, i.e. a dictionary of DataFrames, with Ground Investigation data to an Excel file.
46
+ """Writes a database with Ground Investigation data to an Excel file.
46
47
 
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.
48
+ Each DataFrame in the database dictionary will be saved in a separate Excel sheet named
49
+ after the dictionary keys. This function can be used on any GI database, whether in
50
+ AGS, Bedrock, or another format.
49
51
 
50
52
  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
+ gi_dfs (Dict[str, Union[pd.DataFrame, gpd.GeoDataFrame]]): A dictionary where
54
+ keys are GI table names and values are DataFrames with GI data.
55
+ excel_path (Union[str, Path]): Path to the output Excel file. Can be provided as a
56
+ string or Path object.
53
57
 
54
58
  Returns:
55
- None: This function does not return any value. It writes the DataFrames to an Excel file.
59
+ None
56
60
  """
57
-
58
61
  # Create an Excel writer object
59
62
  with pd.ExcelWriter(excel_path, engine="openpyxl") as writer:
60
- for sheet_name, df in gi_db.items():
63
+ for sheet_name, df in gi_dfs.items():
61
64
  sanitized_sheet_name = sanitize_table_name(sheet_name)
62
65
  if isinstance(df, pd.DataFrame) or isinstance(df, gpd.GeoDataFrame):
63
66
  df.to_excel(writer, sheet_name=sanitized_sheet_name, index=False)
@@ -65,16 +68,18 @@ def write_gi_db_to_excel(
65
68
  print(f"Ground Investigation data has been written to '{excel_path}'.")
66
69
 
67
70
 
71
+ # TODO: Make the 31 character table name length truncation a separate function. Only necessary for Excel.
68
72
  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.
73
+ """Replaces invalid characters and spaces in GI table names with underscores and truncates to 31 characters.
74
+
75
+ Makes table names consistent with SQL, GeoPackage and Excel naming conventions by
76
+ replacing invalid characters and spaces with underscores.
72
77
 
73
78
  Args:
74
79
  sheet_name (str): The original sheet name.
75
80
 
76
81
  Returns:
77
- str: A sanitized sheet name with invalid characters and spaces replaced.
82
+ sanitized_name (str): A sanitized sheet name with invalid characters and spaces replaced.
78
83
  """
79
84
  # Trim to a maximum length of 31 characters
80
85
  trimmed_name = sheet_name.strip()[:31]
@@ -98,6 +103,7 @@ def sanitize_table_name(sheet_name):
98
103
  )
99
104
 
100
105
  # Ensure name isn't empty after sanitization
106
+ # ! "Table1" doesn't make a lot of sense?!? It could be that there are more than 1 table without a name...
101
107
  if not sanitized_name:
102
108
  sanitized_name = "Table1"
103
109
  print("The table name was completely invalid or empty. Replaced with 'Table1'.")
bedrock_ge/plot.py CHANGED
@@ -1,2 +1,4 @@
1
1
  def hello_plt() -> None:
2
- print("Hello from src/bedrock/plot.py!")
2
+ print(
3
+ "Hi Bedrock engineer! bedrock_ge.plot is a placeholder module for Geotechnical Engineering plots."
4
+ )
@@ -0,0 +1,209 @@
1
+ Metadata-Version: 2.4
2
+ Name: bedrock-ge
3
+ Version: 0.2.4
4
+ Summary: Bedrock's Python library for geotechnical engineering.
5
+ Project-URL: Homepage, https://bedrock.engineer/
6
+ Project-URL: Source, https://github.com/bedrock-engineer/bedrock-ge
7
+ Project-URL: Documentation, https://bedrock.engineer/docs/
8
+ Project-URL: Tracker, https://github.com/bedrock-engineer/bedrock-ge/issues
9
+ Author-email: Bedrock <info@bedrock.engineer>
10
+ License: Apache Software License (Apache 2.0)
11
+ License-File: LICENSE
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
16
+ Classifier: License :: OSI Approved :: Apache Software License
17
+ Classifier: Operating System :: OS Independent
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
27
+ Requires-Python: >=3.9
28
+ Requires-Dist: geopandas~=1.0
29
+ Requires-Dist: openpyxl~=3.0
30
+ Requires-Dist: pandera>=0.23.0
31
+ Requires-Dist: python-ags4~=1.0
32
+ Requires-Dist: sqlmodel>=0.0.22
33
+ Description-Content-Type: text/markdown
34
+
35
+ <figure style="margin-inline: block;">
36
+ <img src="https://bedrock.engineer/public/Bedrock_TextRight.png" alt="Bedrock logo" width="75%"/>
37
+ </figure>
38
+
39
+ <h3 style="margin-inline: block;">Bedrock, the Open Source Foundation for Geotechnical Engineering</h3>
40
+
41
+ ---
42
+
43
+ 🌐 **Website:** <https://bedrock.engineer/>
44
+
45
+ 📃 **Documentation:** <https://bedrock.engineer/docs>
46
+
47
+ 📃 **API Reference:** <https://bedrock.engineer/reference/>
48
+
49
+ 🖥️ **Source Code:** <https://github.com/bedrock-engineer/bedrock-ge>
50
+
51
+ 🐍 **`bedrock-ge` on PyPI:** <https://pypi.org/project/bedrock-ge/>
52
+
53
+ 🔗 **LinkedIn:** <https://www.linkedin.com/company/bedrock-engineer>
54
+
55
+ ---
56
+
57
+ ## Overview
58
+
59
+ > **Definition of Bedrock**
60
+ >
61
+ > In an abstract sense, the bedrock refers to the main principles something is based on. [1]
62
+ >
63
+ > In the real world, the bedrock is the hard area of rock in the ground that holds up the loose soil above. [1]
64
+ >
65
+ > In many civil engineering projects, the identification of the bedrock through digging, drilling or geophysical methods is an important task, which greatly influences (geotechnical) design. [2]
66
+ >
67
+ > Sources: [[1] Bedrock | Cambridge Dictionary](https://dictionary.cambridge.org/us/dictionary/english/bedrock), [[2] Bedrock | Wikipedia](https://en.wikipedia.org/wiki/Bedrock)
68
+
69
+ Ground Investigation (GI) data is often trapped in legacy formats that limit analysis and visualization possibilities.
70
+ `bedrock-ge` lets you transform this data from specialized geotechnical formats and common tabular formats (Excel, CSV) into modern, standardized geospatial data.
71
+
72
+ This standardization lets you bridge the gap between raw geotechnical data, the modern Python (geo)scientific ecosystem and modern geospatial tools.
73
+ This gives geotechnical engineers greater flexibility in visualization, modeling, and integration across different software environments while avoiding vendor lock-in.
74
+ For example, this enables connecting your GI data with GIS as well as BIM environments through [platforms like Speckle](#-put-your-gi-data-into-speckle).
75
+
76
+ The purpose of Bedrock is NOT to become THE standard for geotechnical data, because [we don't need 15 instead of 14 competing standards](https://xkcd.com/927/).
77
+
78
+ ## Highlights
79
+
80
+ ### 📖 Read / write Ground Investigation (GI) data in different formats
81
+
82
+ | Data Format | Read | Write |
83
+ | ----------- | ---- | ----- |
84
+ | AGS 3 | ✅ | ❌ |
85
+ | AGS 4 | ✅ | ✅ |
86
+ | Excel | ✅ | ✅ |
87
+ | CSV | ✅ | ✅ |
88
+ | JSON | ✅ | ✅ |
89
+ | GeoJSON | ✅ | ✅ |
90
+
91
+ Do you need another format? Like [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), or something else?
92
+ 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).
93
+
94
+ 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.
95
+
96
+ ### ✅ Validate your GI data
97
+
98
+ `bedrock-ge` comes with data validation to make sure that you can combine Ground Investigation data from multiple files into a single geospatial database with consistent relationships between GI locations, samples, in-situ measurements and lab tests.
99
+
100
+ 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.
101
+
102
+ ### 🗺️ Put your GI data from multiple files into a single 3D geospatial database
103
+
104
+ For example, you can take GI data from 100 AGS files and combine them into a single a [GeoPackage](https://en.wikipedia.org/wiki/GeoPackage) ([like a Shapefile, but then waaay better](http://switchfromshapefile.org/)). Such a GeoPackage can then be loaded into ArcGIS, where you can visualize your GI data in 3D:
105
+
106
+ <figure style="margin-inline: block; display: block;">
107
+ <img src="https://bedrock.engineer/public/images/KaiTak_BrGI_ArcGIS.webp" alt="Kai Tak, Hong Kong, 3D GI data visualization in ArcGIS" width="90%"/>
108
+ <figcaption>
109
+ GI data in Kai Tak, Hong Kong. <a href="https://arcg.is/0r9DG9">Click here to explore for yourself.</a>
110
+ </figcaption>
111
+ </figure>
112
+
113
+ ### 🟦 Put your GI data into Speckle
114
+
115
+ From ArcGIS or QGIS you can publish your GI data to [Speckle](https://speckle.systems/) and then visualize it together with your ground models and civil engineering designs:
116
+
117
+ <figure style="margin-inline: block; display: block;">
118
+ <img src="https://bedrock.engineer/public/images/KaiTak_BrGI_Speckle.png" alt="Kai Tak, Hong Kong, data from many sources in Speckle." width="90%"/>
119
+ <figcaption>
120
+ Models from Rhino, Revit, Civil3D + context & GI data from Q/ArcGIS. <a href="https://app.speckle.systems/projects/013aaf06e7/models/0fa0287ba8,1cbe68ed69,44c8d1ecae,7f9d99cae2,9535541c2b,a739490298,ff81bfa02b">Click here to explore for yourself.</a>
121
+ </figcaption>
122
+ </figure>
123
+
124
+ <figure style="margin-inline: block; display: block;">
125
+ <img src="https://bedrock.engineer/public/images/WekaHills_Speckle.webp" alt="GI data, the derived Leapfrog ground model and a tunnel in Speckle." width="90%"/>
126
+ <figcaption>
127
+ GI data, the derived Leapfrog ground model and a tunnel in Speckle. <a href="https://app.speckle.systems/projects/7a489ac0d4/models/$epsg:2193-7839%2Fgeo%2Fgeology-model,65b4cf97d5,9069ef2b2b">Click here to explore for yourself.</a>
128
+ </figcaption>
129
+ </figure>
130
+
131
+ Moreover, your GI data becomes available in all the software that [Speckle has connectors for](https://app.speckle.systems/downloads).
132
+
133
+ ### 🔓 Free and Open Source Software
134
+
135
+ `bedrock-ge` is Free and Open Source Software (FOSS), meaning it gives you full access to the code, and you can customize `bedrock-ge` to integrate with other tools and fit your workflows and project needs.
136
+
137
+ 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.
138
+
139
+ You can give [feedback](#-feedback) and [contribute](#-contributing), such that together we can build the tools we've always wanted and needed.
140
+
141
+ ## Installation
142
+
143
+ We recommend to use [`uv`](https://docs.astral.sh/uv/) to manage Python for you.
144
+ Using `uv`, you can add `bedrock-ge` to your Python project and install it in your project's virtual environment by running:
145
+
146
+ ```bash
147
+ uv add bedrock-ge
148
+ ```
149
+
150
+ It's also possible to install `bedrock-ge` from [PyPI](https://pypi.org/project/bedrock-ge/) (Python Packaging Index) using `pip`:
151
+
152
+ ```bash
153
+ pip install bedrock-ge
154
+ ```
155
+
156
+ ## Feedback
157
+
158
+ Got some feedback, a great idea, running into problems when working with Bedrock or just want to ask some questions?
159
+
160
+ Please feel free to:
161
+
162
+ 1. Open an issue for feature requests or bug reports: [`bedrock-ge` issues](https://github.com/bedrock-engineer/bedrock-ge/issues),
163
+ 2. Start a discussion in this GitHub repo: [Bedrock discussions](https://github.com/orgs/bedrock-engineer/discussions),
164
+ 3. Or start a discussion on the Speckle community forum if that's more appropriate: [Speckle community forum](https://speckle.community/)
165
+
166
+ All feedback and engagement with the Bedrock community is welcome.
167
+
168
+ ## Contributing
169
+
170
+ Contributing isn't scary. Contributing isn't just about writing code:
171
+
172
+ - Spread the word about Bedrock
173
+ - Use Bedrock and provide [feedback](#-feedback)
174
+ - Share how you use Bedrock
175
+ - 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)
176
+ - Documentation and tutorials
177
+ - 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, click this button to make a contribition.
178
+
179
+ <figure style="margin-inline: block;">
180
+ <img src="https://bedrock.engineer/public/images/EditThisPage.png" alt="Edit this page on GitHub button on bedrock.engineer" width="25%"/>
181
+ </figure>
182
+
183
+ - If you would like to contribute code, awesome!
184
+ Please create an [issue](https://github.com/bedrock-engineer/bedrock-ge/issues) for what you'd like to contribute. If you don't know how to get started, please indicate this in your issue, and we'll help you out.
185
+
186
+ ## Maintainers
187
+
188
+ ### Joost
189
+
190
+ > 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](https://www.arup.com/services/computational-and-parametric-design/).
191
+ >
192
+ > 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).
193
+ >
194
+ > Bedrock is the Free and Open Source Software (FOSS) that I wish existed when I worked as a geotechnical engineer at Arup.
195
+
196
+ ### Jules
197
+
198
+ > I studied Applied Geoscience (Petroleum Engineering Reservoir Geology) but frustration with technical software led me to learn to code and as a result, I mostly worked in software development.
199
+ >
200
+ > Over the past 5 years, I’ve worked on data-rich applications across various domains, specifically in frontend development.
201
+ > My primary interest is figuring out how to build tools for more thoughtful display and processing of technical information, for geoscience in particular.
202
+
203
+ ## Contributors
204
+
205
+ Please take a look at the [contributors page](https://github.com/bedrock-engineer/bedrock-ge/graphs/contributors).
206
+
207
+ ## Professional Support
208
+
209
+ While `bedrock-ge` is an Free Open Source Software (FOSS) project, you might be looking for professional support implementing it, contact <info@bedrock.engineer> for more information.
@@ -0,0 +1,21 @@
1
+ bedrock_ge/__init__.py,sha256=9zw1B8qBymbOqc4p2OJ3e8chmXEihHSBt1Fs1BtnvkQ,89
2
+ bedrock_ge/plot.py,sha256=C95aj8CXjFVZRGYYBssJMm5MyljLbdt_TKyvmQyWZBE,149
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=ewPXau86yDTGE92DlbNlQ7gprBHkqBottzHsPbXbEg0,1519
6
+ bedrock_ge/gi/gis_geometry.py,sha256=QXNjWIGANh_M035Lbc94eOZnNry9f778E8wg_7KgAQo,11669
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=riUa9AaHngJDX0VtUrOEKKfr-sZxybrGqJFmq4kRFnA,7080
10
+ bedrock_ge/gi/write.py,sha256=eCfijylreJ5oNMJqqx_k-Y30FNIHys2NccHilrFm0X4,4319
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=FCeMX1R7IGcZY0heqrHPzs13rytelkmmFaJRklPB7EM,7114
15
+ bedrock_ge/gi/ags/schemas.py,sha256=y36n9SCKqFfoIQ_7-MTEdfArA5vAqZdRpY3wC4fdjy4,7451
16
+ bedrock_ge/gi/ags/transform.py,sha256=NeeR6e3awDf3ITWSxAUW1bXspUXaj-dM7xi1g-Ppxhc,9988
17
+ bedrock_ge/gi/ags/validate.py,sha256=ZfBS7AP_CTguLQCbGeyy4Krz32th2yCmtdG9rvX0MOU,703
18
+ bedrock_ge-0.2.4.dist-info/METADATA,sha256=T2dwdFOQ2OLLEN_vNY_HQ_UVfX_iq1ATlbgDLVmXk7E,11727
19
+ bedrock_ge-0.2.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
20
+ bedrock_ge-0.2.4.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
21
+ bedrock_ge-0.2.4.dist-info/RECORD,,
@@ -1,227 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: bedrock-ge
3
- Version: 0.2.2
4
- Summary: Bedrock's Python library for geotechnical engineering.
5
- Project-URL: Homepage, https://bedrock.engineer/
6
- Project-URL: Source, https://github.com/bedrock-engineer/bedrock-ge
7
- Project-URL: Documentation, https://bedrock.engineer/docs/
8
- Project-URL: Tracker, https://github.com/bedrock-engineer/bedrock-ge/issues
9
- Author-email: Bedrock <info@bedrock.engineer>
10
- License: Apache Software License (Apache 2.0)
11
- License-File: LICENSE
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
16
- Classifier: License :: OSI Approved :: Apache Software License
17
- Classifier: Operating System :: OS Independent
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
27
- Requires-Python: >=3.9
28
- Requires-Dist: geopandas~=1.0
29
- Requires-Dist: openpyxl~=3.0
30
- Requires-Dist: pandera>=0.23.0
31
- Requires-Dist: python-ags4~=1.0
32
- Requires-Dist: sqlmodel>=0.0.22
33
- Description-Content-Type: text/markdown
34
-
35
- <p align="center">
36
- <img src="https://bedrock.engineer/public/Bedrock_TextRight.png" alt="Bedrock logo" width="75%"/>
37
- </p>
38
-
39
- <h3 align="center">Bedrock, the Open Source Foundation for Ground Investigation Data</h3>
40
-
41
- ---
42
-
43
- 📃 **Documentation:** <https://bedrock.engineer/docs>
44
-
45
- 🖥️ **Source Code:** <https://github.com/bedrock-gi/bedrock-gi>
46
-
47
- 🐍 **`bedrock-gi` on PyPI:** <https://pypi.org/project/bedrock-gi/>
48
-
49
- 🌐 **Website:** <https://bedrock.engineer/>
50
-
51
- 🔗 **LinkedIn:** <https://www.linkedin.com/company/bedrock-gi>
52
-
53
- ---
54
-
55
- ## 🌟 Highlights
56
-
57
- ### 📖 Read / write Ground Investigation (GI) data in different formats
58
-
59
- | Data Format | Read | Write |
60
- |-------------|------|-------|
61
- | AGS 3 | ✅ | ❌ |
62
- | AGS 4 | Soon | [python-ags4](https://pypi.org/project/python-AGS4/) |
63
- | Excel | ✅ | ✅ |
64
- | CSV | ✅ | ✅ |
65
- | JSON | ✅ | ✅ |
66
- | GeoJSON | ✅ | ✅ |
67
-
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) 💭
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 🤩
72
-
73
- ### ✅ Validate your GI data
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.
76
-
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
-
79
- ### 🗺️ Put your GI data from multiple files into a single 3D GIS database
80
-
81
- For example, you can take GI data from 100 AGS files and combine them into a single a [GeoPackage](https://en.wikipedia.org/wiki/GeoPackage) ([like a Shapefile, but then waaay better](http://switchfromshapefile.org/)). Such a GeoPackage can then be loaded into ArcGIS, such that you can visualize your GI data in 3D:
82
-
83
- <p align="center">
84
- <img src="https://bedrock.engineer/public/images/KaiTak_BrGI_ArcGIS.gif" alt="GI data visualization .gif in 3D in ArcGIS" width="90%"/>
85
- </p>
86
-
87
- ### 🟦 Put your GI data into Speckle
88
-
89
- Once you have your GI data inside [Speckle](https://speckle.systems/), it's super easy to visualize GI data together with civil engineering designs:
90
-
91
- <p align="center">
92
- <img src="https://bedrock.engineer/public/images/KaiTak_BrGI_Speckle.png" alt="Kai Tak, Hong Kong, data from many sources." width="56%" />
93
- <img src="https://bedrock.engineer/public/images/BPFoundation.png" alt="Bored Pile foundation design." width="40%" />
94
- <a href="https://app.speckle.systems/projects/013aaf06e7/models/0fa0287ba8@dfbec71408,1cbe68ed69@d3c4a34cff,44c8d1ecae@b962e2f29d,7f9d99cae2@bbed7cf165,9535541c2b@fafe06f9c0,a739490298@e858cc8cb3,ff81bfa02b@dda7c2f981" target="_blank">Click here to go to the Kai Tak Speckle project from the left image</a>
95
- </p>
96
-
97
- Moreover, your GI data becomes available in all the software that [Speckle has connectors for](https://app.speckle.systems/downloads).
98
-
99
- ### 🔓 Free and Open Source Software
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.
102
-
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
-
105
- You can give [feedback](#-feedback) and [contribute](#-contributing), such that together we together can build the tools we've always wanted and needed 🤝
106
-
107
- ## ℹ️ Overview
108
-
109
- > **Definition of Bedrock**
110
- >
111
- > In an abstract sense, the main principles on which something is based. [1]
112
- >
113
- > In the real world, the bedrock is the hard area of rock in the ground that holds up the loose soil above. [1]
114
- >
115
- > In many civil engineering projects, the identification of the bedrock through digging, drilling or geophysical methods is an important task, which greatly influences (foundation) design. [2]
116
- >
117
- > Sources: [[1] Bedrock | Cambridge Dictionary](https://dictionary.cambridge.org/us/dictionary/english/bedrock), [[2] Bedrock | Wikipedia](https://en.wikipedia.org/wiki/Bedrock)
118
-
119
- Bedrock, this open source software project, forms the foundation for for ground investigation data, subsurface modelling and Geo-BIM.
120
-
121
- With Bedrock you can get your data from any Ground Investigation data format into a GIS database 🗺️, from a GIS database into Speckle 🟦, and from Speckle into all the software we work with in the AEC industry 🏗️.
122
-
123
- The purpose of Bedrock is NOT to become THE standard for geotechnical data, because we don't need 15 instead of 14 competing standards:
124
-
125
- <p align="center">
126
- <img src="https://bedrock.engineer/public/images/14Become15Standards.png" alt="14 competing standards become 15 competing standards | xkcd.com/927" width="60%"/>
127
- <br>
128
- Source: <a href="https://xkcd.com/927/" target="_blank">https://xkcd.com/927</a>
129
- </p>
130
-
131
- For example, us geotechnical engineers who are used to working with AGS data know that the "ISPT group" is a table that describes an In-Situ Standard Penetration Test and we know what headings, i.e. columns that AGS group, i.e. table has. Therefore, Bedrock doesn't change that the naming of those columns. Bedrock just makes sure that the data is structured in a sensible way, such that Ground Investigation data from multiple sources can be converted into a GIS database.
132
-
133
- A GIS database with Ground Investigation data contains tables that describe the Ground Investigation `'Project'`, the `'Location'`s where GI data was collected, the `'Sample'`s and `'InSitu'` measurements taken at these `'Location'`s, and the `'Lab'` tests that were performed on the collected `'Sample'`s.
134
-
135
- The `'Project'`, `'Location'`, `'Sample'`, `'InSitu'` measurement and `'Lab'` test tables are related to each other: each lab test belongs to a sample, which belongs to a GI location, which belongs to a project. These relationships can be visualized in a hierarchy like this:
136
-
137
- ```bash
138
- 'Project'
139
- └───'Location'
140
- ├───'InSitu'
141
- └───'Sample'
142
- └───'Lab'
143
- ```
144
-
145
- These relationships are represented in the database tables with so-called "foreign keys". For example, the results of an Atterberg Limits Lab test, i.e. Liquid Limit and Plastic Limit tests, that originated from an AGS file would be in stored in the `'Lab_LLPL'` table. Each row in this table represents the Atterberg Limit test results performed on a specific sample. Each row knows to which project, GI location and sample it belongs through its `project_uid`, `location_uid` and `sample_uid` respectively.
146
-
147
- This relational database ([linked tables](https://en.wikipedia.org/wiki/Relational_database)) with Ground Investigation data becomes a GIS database by assigning a (3D) GIS geometry to each of the rows in each of the database tables (except for the `'Project'` table).
148
-
149
- ## ⬇️ Installation
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:
152
-
153
- ```bash
154
- uv add bedrock-gi
155
- ```
156
-
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/)):
158
-
159
- - 🖥️ `uv` Python projects will work on Windows, macOS and Linux.
160
- - 🐍 `uv` [installs and manages](https://docs.astral.sh/uv/#python-management) Python versions.
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
- - In short, 🚀 `uv` is a single tool to replace `pip`, `pip-tools`, `pipx`, `poetry`, `pyenv`, `virtualenv`, `conda` and more...
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`:
165
-
166
- ```bash
167
- pip install bedrock-gi
168
- ```
169
-
170
- ## 💭 Feedback
171
-
172
- Got some feedback, a great idea, running into problems when working with Bedrock or just want to ask some questions?
173
-
174
- Please feel free to:
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),
178
- 3. or start a discussion on the Speckle community forum if that's more appropriate: [Speckle community forum](https://speckle.community/)
179
-
180
- All feedback and engagement with the Bedrock community is welcome 🤗
181
-
182
- ## 👷 Contributing
183
-
184
- 🛑 Wait, please read this too!
185
-
186
- Contributing isn't scary 😄
187
-
188
- Contributing isn't just about writing code:
189
-
190
- - Use Bedrock and provide [feedback](#-feedback) 🪲
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) 🤝
193
- - Spread the word about Bedrock 🤩
194
- - Documentation and tutorials 📃
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! 🖱️💥
196
-
197
- <p align="center">
198
- <img src="https://bedrock.engineer/public/images/EditThisPage.png" alt="Edit this page on GitHub button on bedrock.engineer" width="20%"/>
199
- </p>
200
-
201
- - If you would like to contribute code, AWESOME! 💖
202
- Please create an issue for what you'd like to contribute. If you don't know how to get started, please indicate this in your issue, and we'll help you out.
203
-
204
- ## 🤔 Things to Consider
205
-
206
- ### GIS Data, Projected vs Geodetic CRS's and Heights / Elevations
207
-
208
- Ground investigation data is initially measured in Easting, Northing, z-coordinate, i.e. in a projected Coordinate Reference System (CRS).
209
-
210
- If you want your ground investigation data to go into a GIS database, all GIS geometry needs to use the same CRS.
211
-
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
-
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.
215
-
216
- ## ✍️ Author
217
-
218
- Hi, I'm Joost Gevaert 👋
219
-
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.
221
-
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).
223
-
224
- Bedrock is the Free and Open Source Software (FOSS) that I wish existed when I worked as a geotechnical engineer at Arup.
225
-
226
- > Computational design is a field that involves the use of computer algorithms, simulations, and data analysis to support and enhance the design process. It enables designers to explore vast design spaces, to find solutions to complex design problems, and to make informed decisions based on data-driven insights.
227
- > Source: [Computational design | Arup](https://www.arup.com/services/computational-and-parametric-design/)
@@ -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,,