Geological Model in Python: 3D Block Model and Cross-Section from Boreholes

Geological Model in Python: 3D Block Model and Cross-Section from Boreholes

CalcTree
November 12, 2026

Free 3D geological modelling in Python: fit horizons to borehole logs, draw the map, cross-section and rotating block model for a road cut. Open a copy.

CalcTree
November 12, 2026
Need a calc we don't have yet?

Tell us what you need, or sign up and build it yourself in minutes.

Leave your email and we'll tell you when a template for it is ready:

Required
Thank you!

Your request has been received. We will let you know when it is available.

Sign up

Oops! Something went wrong while submitting the form.

Related templates

No items found.

No items found.

About this Geological Model Example

This page is a worked example of 3D geological modelling in Python, inside a CalcTree calculation page, as a free alternative to a dedicated modelling package for a small site. A handful of boreholes is usually all a road designer has to picture the ground under a cut. The page reads a borehole table (collar level, depth to weathered rock, depth to fresh rock), fits each horizon as a least-squares plane or a thin-plate-spline surface, drapes the outcrop pattern over the ground as a geological map, cuts a section across the proposed road and a long section along it, and draws a rotating three-dimensional block model with the layered geology on its faces. From the fitted horizons it reports the dip and dip direction of the bedding, the depth to rock along the cut, the excavation split by unit, and how well the model predicts a borehole it was not fitted to.

  • Geotechnical engineer or engineering geologist: turn a borehole log into a section and a block model for a cut or a foundation in minutes, and see how much the picture depends on which hole you leave out.
  • Engineer exploring Python in calculations: read a plane fit, a radial basis function surface, a section generator and a 3D drawing in NumPy, SciPy and Matplotlib on one page.
  • Graduate engineer learning engineering geology: edit the borehole table, move the road, change the batter angle and watch the map, the sections and the block respond.

The borehole data on the page is example data made from two planes with a little noise, and the page says so. It is an analysis aid, not a site investigation report. It is an example of what a CalcTree page can do, built with CalcTree AI, not a design method to rely on as is. The model is idealised and its limits are stated on the page. Duplicate it into your own workspace to change the inputs, read the Python, or use it as the starting point for your own analysis, and verify anything you take into a real design.

More info on the Block Model

Inputs

The boreholes live in a table on the page with a row per hole: easting, northing, collar level, depth to weathered rock and depth to fresh rock. Below it you set the site size and grid resolution, the ground surface parameters, the road position and formation level, the cut batter angle, which fitting method to use, which hole to hold out of the fit, and the friction angle and cut face direction for the kinematic comparison. The number of frames in the rotating block is an input too.

Fitting the horizons

Each contact point is the collar level less the logged depth. With the plane option the horizon is the least-squares plane through those points, and its dip and dip direction come straight from the plane coefficients. With the surface option a thin-plate-spline radial basis function with a linear trend passes through every point, so an undulating horizon is honoured. Where a horizon rises above the ground it is clipped to the surface, which is what makes the outcrop map.

Sections and the block

The section across the road shows the ground, the fitted horizons, the formation level and the batters, and the page reports the cut depth, the depth to rock at the centreline and the excavated area split into soil, weathered rock and fresh rock. The long section follows the road, and the block model draws the same horizons on the faces of a rotating block with the boreholes standing on their collars.

Bedding against the cut batter

From the dip and dip direction of the top of rock the page reports three plain comparisons in the form used for planar sliding by Hoek and Bray: whether the bedding daylights in the cut face, whether it dips more steeply than the friction angle, and whether its direction lies within twenty degrees of the face. These are reported as results with a sentence, not as a verdict; a kinematic check is the start of a slope assessment, not the end.

Checking the analysis

The three-point problem is worked by hand in the visible maths from three boreholes, with the cross product of two in-plane vectors giving the dip and dip direction, and compared with the Python least-squares plane on the same three points. The surface fit is also checked by sampling a known plane at every borehole and confirming it returns that plane at the cut. One agreement chip reports both. The leave-one-out prediction at the held-out hole is reported against the logged depth as a result.

Python libraries used

NumPy holds the borehole table, fits the planes and builds the grid. SciPy provides the thin-plate-spline interpolator for the undulating surface option. Matplotlib draws the geological map, both sections, the three-point plan, the prediction chart, the rotating block model and the design sketch.

Common Calculation Errors to Avoid

  • Mixing depths and levels: a log records depth below collar, and the model needs a reduced level. Subtract every depth from its own collar, and check the collars were surveyed, not read from a map.
  • Fitting a surface to three holes: three points define a plane exactly and give no measure of fit. Hold one hole out and compare the prediction with the log before trusting any horizon.
  • Extrapolating past the holes: both the plane and the spline will happily continue beyond the drilled area, and the spline can swing wildly there. Treat anything outside the borehole footprint as a guess.
  • Confusing dip direction and strike: dip direction is the azimuth the horizon falls toward, ninety degrees from strike. The kinematic comparison needs the dip direction against the cut face direction.
  • Treating the kinematic comparison as a stability check: daylighting bedding above the friction angle means sliding is possible, not that it will happen. Water, persistence and joint roughness decide that, and belong in a proper analysis.
  • Reading example data as a site: the boreholes on the page are synthetic. Replace every row with your own logs before any number leaves the page.
Explore the wide range of resources available
200+

Engineering templates

50+

Common calculators

20+

Design guides

Ready to try?
Streamline your engineering workflows today!
Join engineers from top firms who've signed up
AECOM
ARCADIS
Jacobs
MOTT MACDONALD

FAQs

Can I build a geological model without dedicated modelling software?

For a small site with a handful of boreholes and a few horizons, yes. A least-squares plane or a thin-plate spline through the logged contacts gives a horizon surface, and sections, a map and a block model follow from it. A dedicated package earns its place when there are faults, many units and hundreds of holes.

When should I use the plane fit and when the spline?

Use the plane when the bedding is close to planar and you want a dip and dip direction; it averages the noise in the logs. Use the spline when the horizon undulates and you want it to pass through every contact. Compare the held-out hole prediction for both before choosing.

How does the page get dip and dip direction from boreholes?

It fits a plane to the contact levels and reads the dip from the plane's gradient and the dip direction from the direction it falls. The visible maths also works the classical three-point problem by hand from three holes, so you can see the two agree.

What does the leave-one-out prediction tell me?

How well the model would have predicted a hole before it was drilled. The page refits the top of rock without the hole you choose, predicts the depth at its collar and reports the difference from the logged depth, with the root-mean-square over all holes as a summary.

Does the page check the cut slope for stability?

No. It reports whether the bedding daylights in the cut, dips more steeply than the friction angle and lies within the lateral limit of the face, as the planar-sliding kinematic test does. That tells you whether a slide along bedding is geometrically possible, and a stability analysis takes it from there.

Can I use my own boreholes?

Yes. Duplicate the page and edit the borehole table: a row per hole with coordinates, collar level and the two depths. Every map, section and result updates from the table.

Related templates

Turn your documents into calcs like this one

Upload your documents and project files, then let AI generate and review calcs grounded in your context, not guesswork.