Visualization¶
SoilPlot ¶
Create interactive visualizations for soil and CPT datasets.
Examples:
>>> from unittest.mock import Mock
>>> plotter = SoilPlot(Mock())
>>> isinstance(plotter, SoilPlot)
True
Initialize a plotting helper with a soil API instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
soil_api
|
SoilAPI
|
API client used to fetch soil/CPT data. |
required |
Examples:
Source code in src/owi/metadatabase/soil/visualization/soil_visualizer.py
Functions¶
plot_soilprofile_fence ¶
plot_soilprofile_fence(
soilprofiles_df,
start,
end,
plotmap=False,
fillcolordict=None,
logwidth=100.0,
show_annotations=True,
general_layout=None,
**kwargs,
)
Create a fence diagram for selected soil profiles.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
soilprofiles_df
|
DataFrame
|
Summary rows for selected soil profiles. |
required |
start
|
str
|
Location name used as start point. |
required |
end
|
str
|
Location name used as end point. |
required |
plotmap
|
bool
|
If |
False
|
fillcolordict
|
dict[str, str] or None
|
Soil-type color mapping. |
None
|
logwidth
|
float
|
Width of log traces. |
100.0
|
show_annotations
|
bool
|
Toggle annotations in the output figure. |
True
|
general_layout
|
dict[Any, Any] or None
|
Extra layout parameters. |
None
|
**kwargs
|
Forwarded to profile plotting utilities. |
{}
|
Returns:
| Type | Description |
|---|---|
dict[str, list[DataFrame] | Figure]
|
Dictionary containing loaded profiles and fence diagram. |
Examples:
>>> import pandas as pd
>>> from unittest.mock import Mock
>>> plotter = SoilPlot(Mock())
>>> sample = pd.DataFrame(
... columns=[
... "projectsite_name",
... "location_name",
... "title",
... "easting",
... "northing",
... "elevation",
... ]
... )
>>> plotter.plot_soilprofile_fence(sample, "A", "B")
Source code in src/owi/metadatabase/soil/visualization/soil_visualizer.py
plot_combined_fence
staticmethod
¶
plot_combined_fence(
profiles,
cpts,
startpoint,
endpoint,
band=1000.0,
scale_factor=10.0,
extend_profile=True,
show_annotations=True,
general_layout=None,
fillcolordict=None,
logwidth=100.0,
opacity=0.5,
uniformcolor=None,
**kwargs,
)
Create a combined fence for profiles and CPTs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
profiles
|
list[DataFrame]
|
Georeferenced soil profiles. |
required |
cpts
|
list[DataFrame]
|
Georeferenced CPT objects. |
required |
startpoint
|
str
|
Start location name. |
required |
endpoint
|
str
|
End location name. |
required |
band
|
float
|
Corridor width in meters. |
1000.0
|
scale_factor
|
float
|
Horizontal scale for CPT traces. |
10.0
|
extend_profile
|
bool
|
Extend profile projection to start/end. |
True
|
show_annotations
|
bool
|
Toggle annotations. |
True
|
general_layout
|
dict[Any, Any] or None
|
Extra Plotly layout options. |
None
|
fillcolordict
|
dict[str, str] or None
|
Soil color map. |
None
|
logwidth
|
float
|
Width of profile traces. |
100.0
|
opacity
|
float
|
Profile opacity. |
0.5
|
uniformcolor
|
str or None
|
Single CPT trace color override. |
None
|
**kwargs
|
Forwarded to groundhog plotting utilities. |
{}
|
Returns:
| Type | Description |
|---|---|
dict[str, Figure]
|
Dictionary containing the combined diagram. |
Examples:
Source code in src/owi/metadatabase/soil/visualization/soil_visualizer.py
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 | |
plot_testlocations ¶
Plot test locations on an OpenStreetMap-backed scatter plot.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
return_fig
|
bool
|
If |
False
|
**kwargs
|
Forwarded to :meth: |
{}
|
Returns:
| Type | Description |
|---|---|
Figure or None
|
Figure object when |
Examples:
>>> from unittest.mock import Mock
>>> import pandas as pd
>>> api = Mock()
>>> api.get_testlocations.return_value = {
... "data": pd.DataFrame(
... {
... "northing": [50.0],
... "easting": [2.0],
... "title": ["T"],
... "projectsite_name": ["P"],
... "description": [""],
... }
... )
... }
>>> fig = SoilPlot(api).plot_testlocations(return_fig=True)
>>> fig.__class__.__name__
'Figure'
Source code in src/owi/metadatabase/soil/visualization/soil_visualizer.py
plot_cpt_fence ¶
plot_cpt_fence(
cpt_df,
start,
end,
band=1000.0,
scale_factor=10.0,
extend_profile=True,
plotmap=False,
show_annotations=True,
general_layout=None,
uniformcolor=None,
**kwargs,
)
Create a fence diagram for selected CPTs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cpt_df
|
DataFrame
|
CPT summary rows. |
required |
start
|
str
|
Start location. |
required |
end
|
str
|
End location. |
required |
band
|
float
|
Corridor width in meters. |
1000.0
|
scale_factor
|
float
|
Width scaling for CPT traces. |
10.0
|
extend_profile
|
bool
|
Extend the profile line to start/end. |
True
|
plotmap
|
bool
|
If |
False
|
show_annotations
|
bool
|
Toggle annotations in the figure. |
True
|
general_layout
|
dict[Any, Any] or None
|
Extra layout options. |
None
|
uniformcolor
|
str or None
|
Single color for all CPT traces. |
None
|
**kwargs
|
Forwarded to plotting utility. |
{}
|
Returns:
| Type | Description |
|---|---|
dict[str, list[DataFrame] | Figure]
|
Dictionary with loaded CPT objects and fence figure. |
Examples:
>>> import pandas as pd
>>> from unittest.mock import Mock
>>> plotter = SoilPlot(Mock())
>>> sample = pd.DataFrame(
... columns=[
... "projectsite_name",
... "location_name",
... "title",
... "test_type_name",
... "easting",
... "northing",
... "elevation",
... ]
... )
>>> plotter.plot_cpt_fence(sample, "A", "B")
Source code in src/owi/metadatabase/soil/visualization/soil_visualizer.py
278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 | |