# Geological section

**URL:** <https://forum.generic-mapping-tools.org/t/geological-section/5537>\
**Category:** Q&A\
**Created:** [November 19, 2024, 11:05am UTC](https://forum.generic-mapping-tools.org/t/geological-section/5537 "2024-11-19T11:05:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![affe73](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/affe73/32/4575_2.png) [@affe73](https://forum.generic-mapping-tools.org/u/affe73)\
**Post date:** [November 19, 2024, 11:05am UTC](https://forum.generic-mapping-tools.org/t/geological-section/5537/1 "2024-11-19T11:05:39Z")

</div>

Hi,  
I wonder if GMT can be used to create simple geological sections based on data imported from borehole geological records. Thanks in advanced for sharing your knowledge. Best regards

---

<div class="post-metadata">

**Author:** ![bwwjohnson](https://avatars.discourse-cdn.com/v4/letter/b/f19dbf/32.png) [@bwwjohnson](https://forum.generic-mapping-tools.org/u/bwwjohnson)\
**Post date:** [November 19, 2024, 2:04pm UTC](https://forum.generic-mapping-tools.org/t/geological-section/5537/3 "2024-11-19T14:04:21Z")

</div>

Sorry about that fluffed up the script.

You’ll want to use the [gmt project](https://docs.generic-mapping-tools.org/dev/project.html) module if you have xyz borehole data to project. This will just make a section with some points on it, and you’ll have to fill in the interpretative bits yourself. I’m not aware of anything in gmt that can create a geological cross section from borehole data…maybe you can use [gmt greenspline](https://docs.generic-mapping-tools.org/6.5/greenspline.html#index-0) to interpolate between the points and make a contact? Not something I’ve tried.

Here’s a short example. I used bash arrays for the points but if you want to use a file, you can `cat` or `awk` it and pipe to the `gmt project ....` line.

I can’t remember how to make it so the depths aren’t negative, sorry.

```auto
#!/bin/bash
gmt gmtset FORMAT_GEO_MAP D
file="test_project"
bounds=-R69.0/72.0/37.5/39.5
proj=-JM20c

# profile params
elon=70.5
elat=39.0
slon=70.5
slat=38.0
#profile width / km, angle / deg , z range
wid=100
prof_dip=90
# perpendicular z scale
max_depth=-15
min_depth=0
#set section length and height / cm
proj_len=20
proj_hgt=5

# get profile distance / km
gmt mapproject -Af -G+k << EOF > tmp_distances
$slon $slat
$elon $elat
EOF
sect_dist=`awk 'NR==2{printf("%d",$4)}' tmp_distances`

point1[1]=70.1 
point1[2]=38.7
point1[3]=-7.5

point2[1]=71
point2[2]=38.4
point2[3]=-2

gmt begin $file
    # plot topo
    gmt grdimage @earth_relief_30s_g $bounds $proj -I+a-45+nt1+m0 -Bxa0.5f0.5 -Bya0.5f0.5
    # plot points on map
    echo ${point1[1]} ${point1[2]} | gmt plot -Sc0.2 -W1p,black -Gred
    echo ${point2[1]} ${point2[2]} | gmt plot -Sc0.2 -W1p,black -Gblue

    # plot section line on map
gmt plot -W2p,- << EOF
$slon $slat
$elon $elat
EOF
    # plot end of section symbols on map
    echo $slon $slat | gmt plot -St1 -W1p,black -Gorange
    echo $elon $elat | gmt plot -St1 -W1p,black -Gpurple

    # starting cross section
    # define cross section projection and boundaries and offset from map
    proj2=-JX$proj_len/$proj_hgt
    bounds2=-R-5/$((sect_dist + 5))/$max_depth/$min_depth
    ori2="-Xa0 -Ya-6"

    # define cross section basemap and axes
    gmt basemap $proj2 $bounds2 $ori2 -BwSEn -Bpxa20+l"Distance along section (km)" -Bpya2+l"Depth (km)"

    # plot end of section symbols on section
    echo 0 $perp_max_z 0 | gmt plot $proj2 $bounds2 $ori2 -Si0.8c -W0.3p -Gpurple
    echo $sect_dist $perp_max_z 0 | gmt psxy $proj2 $bounds2 $ori2 -Si0.8c -W0.3p -Gorange

    # project points
    echo ${point1[*]} | gmt project -Q -C$slon/$slat -E$elon/$elat -W-$wid/$wid -Fpz -S -Lw | gmt plot $bounds2 $proj2 $ori2 -Sc0.2 -Gblue 
    echo ${point2[*]} | gmt project -Q -C$slon/$slat -E$elon/$elat -W-$wid/$wid -Fpz -S -Lw | gmt plot $bounds2 $proj2 $ori2 -Sc0.2 -Gred
gmt end show

```

---

<div class="post-metadata">

**Author:** ![affe73](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/affe73/32/4575_2.png) [@affe73](https://forum.generic-mapping-tools.org/u/affe73)\
**Post date:** [November 19, 2024, 7:26pm UTC](https://forum.generic-mapping-tools.org/t/geological-section/5537/4 "2024-11-19T19:26:58Z")

</div>

Hello and thanks very much for your tips. I will try this, hope that it works 🙂
