77@app .cell
88def _ ():
99 import marimo as mo
10- return (mo ,)
10+ import pandas as pd
11+ import geopandas as gpd
12+ from bedrock_ge .gi .geospatial import create_brgi_geodb
13+ from bedrock_ge .gi .mapper import map_to_brgi_db
14+ from bedrock_ge .gi .mapping_models import (
15+ BedrockGIMapping ,
16+ ProjectTableMapping ,
17+ LocationTableMapping ,
18+ InSituTestTableMapping ,
19+ )
20+ from bedrock_ge .gi .write import write_brgi_db_to_file
21+ from bedrock_ge .gi .io_utils import geodf_to_df
22+ from pyproj import CRS
23+ return (
24+ BedrockGIMapping ,
25+ CRS ,
26+ InSituTestTableMapping ,
27+ LocationTableMapping ,
28+ ProjectTableMapping ,
29+ create_brgi_geodb ,
30+ map_to_brgi_db ,
31+ mo ,
32+ pd ,
33+ write_brgi_db_to_file ,
34+ )
1135
1236
1337@app .cell (hide_code = True )
@@ -29,8 +53,117 @@ def _(mo):
2953@app .cell
3054def _ (mo ):
3155 nb_dir = mo .notebook_location ()
32- gi_csvs = [file .name for file in nb_dir .iterdir () if (file .is_file () and file .suffix .lower () == ".csv" )]
56+ gi_csvs = [
57+ file .name
58+ for file in nb_dir .iterdir ()
59+ if (file .is_file () and file .suffix .lower () == ".csv" )
60+ ]
3361 gi_csvs
62+ return gi_csvs , nb_dir
63+
64+
65+ @app .cell (hide_code = True )
66+ def _ (mo ):
67+ mo .md (r"""All borehole inclinations are 90°, so vertical, so there's no need to bother with the borehole inclination, i.e. survey data:""" )
68+ return
69+
70+
71+ @app .cell
72+ def _ (gi_csvs , nb_dir , pd ):
73+ bh_inclination_df = pd .read_csv (nb_dir / gi_csvs [5 ])
74+ bh_inclination_df ["Inclination" ].unique ()
75+ return
76+
77+
78+ @app .cell
79+ def _ (gi_csvs , nb_dir , pd ):
80+ bh_location_df = pd .read_csv (nb_dir / gi_csvs [0 ])
81+ cpt_data_df = pd .read_csv (nb_dir / gi_csvs [1 ])
82+ cpt_location_df = pd .read_csv (nb_dir / gi_csvs [2 ])
83+ geol_df = pd .read_csv (nb_dir / gi_csvs [3 ])
84+ spt_df = pd .read_csv (nb_dir / gi_csvs [4 ])
85+ spt_df
86+ return bh_location_df , geol_df , spt_df
87+
88+
89+ @app .cell
90+ def _ (
91+ BedrockGIMapping ,
92+ CRS ,
93+ InSituTestTableMapping ,
94+ LocationTableMapping ,
95+ ProjectTableMapping ,
96+ bh_location_df ,
97+ create_brgi_geodb ,
98+ geol_df ,
99+ map_to_brgi_db ,
100+ mo ,
101+ spt_df ,
102+ ):
103+ brgi_geodb = create_brgi_geodb (
104+ map_to_brgi_db (
105+ BedrockGIMapping (
106+ Project = ProjectTableMapping (
107+ data = {
108+ "name" : "Weka Hills Leapfrog demo project" ,
109+ "description" : "Weka Hills is a ficticious location in New Zealand that is used in Leapfrog Works training." ,
110+ },
111+ project_id = "WekaHills" ,
112+ horizontal_crs = CRS ("EPSG:2193" ),
113+ vertical_crs = CRS ("EPSG:7839" ),
114+ ),
115+ Location = LocationTableMapping (
116+ data = bh_location_df ,
117+ location_id_column = "LocationID" ,
118+ easting_column = "Easting" ,
119+ northing_column = "Northing" ,
120+ ground_level_elevation_column = "GroundLevel" ,
121+ depth_to_base_column = "FinalDepth" ,
122+ ),
123+ InSitu = [
124+ InSituTestTableMapping (
125+ table_name = "Geology" ,
126+ data = geol_df ,
127+ location_id_column = "HoleID" ,
128+ depth_to_top_column = "from" ,
129+ depth_to_base_column = "to" ,
130+ ),
131+ InSituTestTableMapping (
132+ table_name = "SPT" ,
133+ data = spt_df ,
134+ location_id_column = "holeid" ,
135+ depth_to_top_column = "from" ,
136+ depth_to_base_column = "to" ,
137+ ),
138+ ],
139+ )
140+ )
141+ )
142+
143+ cols = brgi_geodb .Location .columns
144+ brgi_geodb .Location = brgi_geodb .Location .drop (columns = ["Easting" , "Northing" ])
145+ print (cols )
146+ mo .callout ('When the column name in the data is the same (case insensitive) as one of the Bedrock GI standard column names, writing to a database such as GeoPackage becomes impossible. For the Weka Hills GI data this means that "Easting" & "easting" and "Northing" & "northing" cause a conflict.' , kind = "danger" )
147+ return (brgi_geodb ,)
148+
149+
150+ @app .cell (hide_code = True )
151+ def _ (mo ):
152+ mo .md (r"""The Weka Hills is a fictional location in New Zealand, therefore it looks like some of the boreholes are in the water 🙄""" )
153+ return
154+
155+
156+ @app .cell
157+ def _ (brgi_geodb ):
158+ brgi_geodb .LonLatHeight .explore ()
159+ return
160+
161+
162+ @app .cell
163+ def _ (brgi_geodb , mo , write_brgi_db_to_file ):
164+ write_brgi_db_to_file (
165+ brgi_geodb , mo .notebook_dir () / "wekahills_gi.gpkg" , driver = "GPKG"
166+ )
34167 return
35168
36169
0 commit comments