# A Python Application for Visualizing the 3D Stratigraphic Architecture of the Onshore Llobregat River Delta in NE Spain

^{1}

^{2}

^{3}

^{4}

^{5}

^{*}

## Abstract

**:**

## 1. Introduction

^{2}, forming the southwestern sector of the metropolitan area of Barcelona city in the Catalonia region in northeastern Spain (Figure 1). This area also includes other minor-order cities such as El Prat de Llobregat, L’Hospitalet de Llobregat, Cornellà, Sant Boi, Viladecans, Gavà and Castelldefels. The permanent surface-water provision and the abundance of groundwater have favored the development of coastal aquatic ecosystems and human settlements since ancient times. During the XIX and XX centuries, a large industrial activity developed in the area. Since the second half of the XX century, the high groundwater exploitation rates to supply to the increasing population and industrial activity produced negative consequences on groundwater quantity and quality, including seawater intrusion into aquifers and high levels of pollution [1]. Other modern development milestones occurred in Barcelona city and its metropolitan area, such as the Olympic Games in 1992 and the Llobregat Delta Infrastructure and Environment Plan (Pla d’Infraestructures i Medi Ambient del Delta del Llobregat, PDL) started in 1994 [2] have modified the LRD land use and geomorphology. The PDL included large civil infrastructures with variable underground development such as the extension of the International Airport and Harbor of Barcelona, a dense network of new highways, different underground lines, conventional and high-speed railways, wastewater new treatment plants, desalination plants, diversion of the Llobregat River final section, and many other civil works.

## 2. Geological and Hydrological Setting

^{2}[20]. The Llobregat River shows an irregular streamflow regime in the 250–1500 Mm

^{3}range determined by a Mediterranean-like climate regime [11]. The deltaic plain is also modeled by several ephemeral streams coming from the Garraf and Collserola massifs [17]. Apart from this hydrological control, the LRD coastal fringe has also been modified by the regional littoral drift towards the SW. In this area, littoral currents of about 30 cm s

^{–1}redistribute the sediments to the SW also bringing sediments from northern rivers and streams [36,37]. To a lesser extent, the waves (low energy) and the tide (a few centimeters) contribute to the sediment’s redistribution in the coastal areas of the LRD [36,37].

## 3. Materials and Methods

#### 3.1. Python Programing Language

#### 3.2. Data Compilation and Pretreatment

**Figure 3.**A selected geotechnical borehole (SM P-4, location in Figure 1), showing the granulometry tests (red arrows) performed through the Spanish standards and their results for gravel (cyan), coarse sand (yellow), and silt–clay (gray) granulometry classes. This information forms part of the granulometry dataset generated by the METALL used in this paper.

#### 3.3. The 3D Mapping of the Boreholes Granulometry Classes

#### 3.4. The 3D Mapping of the Stratigraphic Architecture

#### 3.5. The 3D Mapping of the Basement Top Surface

## 4. Results

#### 4.1. The 3D Mapping of the Boreholes Granulometry Classes

#### 4.2. The 3D Stratigraphic Architecture of the Quaternary Coarse Detritic Lithosomes

#### 4.3. The 3D Mapping of the Basement Top Surface

^{2}onshore surface of the LRD into account, after several trials, the optimal regular mapping grid was 100 m × 100 m (n = 100), the block radius was 5 (r = 5), and the p-value was 2 (p = 2). Figure 10 shows the 3D HTML model created to display the 3D mapping of the basement top surface. An interactive 3D HTML version of this model (3D_Basement_LRD.html) is provided as supplementary material. The plotting adopted a 1:1:50 (x = 2, y = 2 and z = 0.5) aspect ratio to show three different zenithal, SE–NW frontal and NE–SW lateral frontal views. This model also allows different views, zooming, rotating, and moving around, as well as hiding elements to focus on details.

## 5. Discussion

## 6. Conclusions

## Supplementary Materials

## Author Contributions

## Funding

## Institutional Review Board Statement

## Informed Consent Statement

## Data Availability Statement

## Acknowledgments

## Conflicts of Interest

## Appendix A

#### Appendix A.1. Data Handling

- ${\left[1\right]}$:
- DATADIR=‘data/’# Directory with the dataFIGURESDIR=‘figures/’# Figures produced

- ${\left[2\right]}$:
- import functionsfrom functions import *

- ${\left[3\right]}$:
- data=pd.read_csv(DATADIR+’data.csv’)

#### Appendix A.1.1. Granulometry Data

- ${\left[4\right]}$:
- clays=data.loc[(data[‘Clase’]==‘arcillas y limos’)]sands=data.loc[(data[‘Clase’]==‘arenas’)]gravels=data.loc[(data[‘Clase’]==‘gravillas y gravas’)]basement=data.loc[(data[‘Valor’]==‘S’)]And save those data to CSV files.

- ${\left[5\right]}$:
- clays.to_csv(DATADIR+’clays.csv’,index=False)sands.to_csv(DATADIR+’sands.csv’,index=False)gravels.to_csv(DATADIR+’gravels.csv’,index=False)basement.to_csv(DATADIR+’basement.csv’,index=False)

#### Appendix A.1.2. Stratigraphic Intervals

- ${\left[6\right]}$:
- up_clays=clays.loc[(clays[‘Cota’]>-21)]up_clays.to_csv(DATADIR+’up_clays.csv’,index=False)mid_clays=clays.loc[(clays[‘Cota’]>-51)&(clays[‘Cota’]<-20)]mid_clays.to_csv(DATADIR+’mid_clays.csv’,index=False)low_clays=clays.loc[(clays[‘Cota’]<-50)]low_clays.to_csv(DATADIR+’low_clays.csv’,index=False)

- ${\left[7\right]}$:
- up_sands=sands.loc[(sands[‘Cota’]>-21)]up_sands.to_csv(DATADIR+’up_sands.csv’,index=False)mid_sands=sands.loc[(sands[‘Cota’]>-51)&(sands[‘Cota’]<-20)]mid_sands.to_csv(DATADIR+’mid_sands.csv’,index=False)low_sands=sands.loc[(sands[‘Cota’]<-50)]low_sands.to_csv(DATADIR+’low_sands.csv’,index=False)

- ${\left[8\right]}$:
- up_gravels=gravels.loc[(gravels[‘Cota’]>-21)]up_gravels.to_csv(DATADIR+’up_gravels.csv’,index=False)mid_gravels=gravels.loc[(gravels[‘Cota’]>-51)&(gravels[‘Cota’]<-20)]mid_gravels.to_csv(DATADIR+’mid_gravels.csv’,index=False)low_gravels=gravels.loc[(gravels[‘Cota’]<-50)]low_gravels.to_csv(DATADIR+’low_gravels.csv’,index=False)

#### Appendix A.2. The 3D Mapping of the Boreholes Granulometry Classes: The 3D_Boreholes_LRD.Html File

- ${\left[9\right]}$:
- clays=pd.read_csv(DATADIR+’clays.csv’)sands=pd.read_csv(DATADIR+’sands.csv’)gravels=pd.read_csv(DATADIR+’gravels.csv’)basement=pd.read_csv(DATADIR+’basement.csv’)We have used Google Earth to draw the LRD contour and we have created the file ‘deltacon-tourn.csv’ with the corresponding data. We read this file.

- ${\left[10\right]}$:
- deltacontourn=pd.read_csv(DATADIR+’deltacontourn.csv’)The function coordinates (data, positions) lists the X, Y and Z UTM coordinates extracted from ’data’ by looking at the data indicated at ’positions’.

- ${\left[11\right]}$:
- xyzcontourn=coordinates(DATADIR+’deltacontourn.csv’,[0,1,2])xyzclays=coordinates(DATADIR+’clays.csv’,[1,2,3])xyzsands=coordinates(DATADIR+’sands.csv’,[1,2,3])xyzgravels=coordinates(DATADIR+’gravels.csv’,[1,2,3])xyzbasement=coordinates(DATADIR+’basement.csv’,[1,2,3])The function bounds (list) returns some bounds of ’list’, where ’list’ is a list obtained using the above function ’coordinates’. These bounds are used to delimit the bounds of the figure we are going to create.

- ${\left[12\right]}$:
- bounds=bounds(xyzcontourn)We use the ’Polygon’ function to create a 2D polygon with the X and Y coordinates of the LRD contour.

- ${\left[13\right]}$:
- contourn_poly=Polygon(zip(xyzcontourn [0],xyzcontourn [1]))The near(xyz,polyg,dis) function uses the geometry function ’distance’ to select coordinates in the ’xyz’ list that are within a distance less than ’dis’ from the polygon ’polyg’.

- ${\left[14\right]}$:
- xyzclays_near=nearby(xyzclays,contourn_poly,300)xyzsands_near=nearby(xyzsands,contourn_poly,300)xyzgravels_near=nearby(xyzgravels,contourn_poly,300)xyzbasement_near=nearby(xyzbasement,contourn_poly,300)

- ${\left[15\right]}$:
- cls_data=data_p([xyzclays_near,xyzsands_near,xyzgravels_near,xyzbasement_near],[‘Clays’,’Sands’,’Gravels’,’Basement’],[‘grey’,’yellow’,’lightskyblue’,’red’],[‘circle’,’circle’,’circle’,’circle’],1.5)

- ${\left[16\right]}$:
- xyzdat=coordinates(DATADIR+’boreholes.csv’,[1,2,3])xyzdat_near=nearby(xyzdat,contourn_poly,300)marks_dat=data_p([xyzdat_near],[‘marks for all boreholes’],[‘black’],[‘circle’],3)Now we built the figure and create the HTML file.

- ${\left[17\right]}$:
- dat=marks_dat+cls_data

- ${\left[18\right]}$:
- fig=go.Figure(data=dat)fig.add_trace(go.Scatter3d(x=xyzcontourn [0],y=xyzcontourn [1],z=xyzcontourn [2],mode=‘lines’,line_width=5,name=‘Delta Contour’,marker = dict (size = 4, color = ‘black’)))fig.update_layout( title=‘3D boreholes Llobregat Delta, Z scale is x 50.’,scene=dict(aspectratio=dict(x=2, y=2, z=0.5),xaxis = dict(range=[bounds [0]-2000,bounds [1]+2000],),yaxis = dict(range=[bounds [2]-2000,bounds [3]+2000])))#fig.show()go_offline.plot(fig,filename=FIGURESDIR+’3D_Boreholes_LRD.html’,validate=True, autoopen=False)

#### Appendix A.3. The 3D Stratigraphic Architecture of the Quaternary Coarse Detritic Lithosomes: The 3D_Lithosomes_LRD.Html File

- ${\left[19\right]}$:
- up_sands=pd.read_csv(DATADIR+’up_sands.csv’)mid_sands=pd.read_csv(DATADIR+’mid_sands.csv’)low_sands=pd.read_csv(DATADIR+’low_sands.csv’)

- ${\left[20\right]}$:
- up_gravels=pd.read_csv(DATADIR+’up_gravels.csv’)mid_gravels=pd.read_csv(DATADIR+’mid_gravels.csv’)low_gravels=pd.read_csv(DATADIR+’low_gravels.csv’)Now we apply the function ’coordinates’ to extract the coordinates from the data.

- ${\left[21\right]}$:
- xyzup_sands=coordinates(DATADIR+’up_sands.csv’,[1,2,3])xyzmid_sands=coordinates(DATADIR+’mid_sands.csv’,[1,2,3])xyzlow_sands=coordinates(DATADIR+’low_sands.csv’,[1,2,3])

- ${\left[22\right]}$:
- xyzup_gravels=coordinates(DATADIR+’up_gravels.csv’,[1,2,3])xyzmid_gravels=coordinates(DATADIR+’mid_gravels.csv’,[1,2,3])xyzlow_gravels=coordinates(DATADIR+’low_gravels.csv’,[1,2,3])The function nearby reduces de coordinates to those inside the delta contour.

- ${\left[23\right]}$:
- xyzup_sands_near=nearby(xyzup_sands,contourn_poly,300)xyzmid_sands_near=nearby(xyzmid_sands,contourn_poly,300)xyzlow_sands_near=nearby(xyzlow_sands,contourn_poly,300)

- ${\left[24\right]}$:
- xyzup_gravels_near=nearby(xyzup_gravels,contourn_poly,300)xyzmid_gravels_near=nearby(xyzmid_gravels,contourn_poly,300)xyzlow_gravels_near=nearby(xyzlow_gravels,contourn_poly,300)The function ’zipxyz’ will return an iterator that generates tuples of length 3. It is just as the python zip function but adapted to our context.

- ${\left[25\right]}$:
- zipxyzup_sands=zipxyz(xyzup_sands_near)zipxyzmid_sands=zipxyz(xyzmid_sands_near)zipxyzlow_sands=zipxyz(xyzlow_sands_near)

- ${\left[26\right]}$:
- zipxyzup_gravels=zipxyz(xyzup_gravels_near)zipxyzmid_gravels=zipxyz(xyzmid_gravels_near)zipxyzlow_gravels=zipxyz(xyzlow_gravels_near)Looking at the Figure 3D_boreholes_LRD.html we observe several clusters of material, which will form the lithosomes. In order to define those clusters of points, we start by selecting a point in each one of them. We classify the start points by granulometry (sands and gravels) and height (up, mid, low).

- ${\left[27\right]}$:
- p_up=[[425819,4572468,-4],[427520,4578010,-13],[422263,4572006,-2],[427654,4573304,-7],[423805,4575000,1],[415204,4570091,-4]]p_mid=[[422597,4572114,-42],[428622,4575033,-32]]p_low=[[422542,4571860,-53]]

- ${\left[28\right]}$:
- q_up=[[428690,4574580,-12],[421651,4579184,-5],[416530,4572040,-20],[420520,4576590,-11],[425311,4576090,4]]q_mid=[[421606,4578734,-24],[427841,4578673,-21],[416955,4571630,-28],[423325,4575350,-37],[419480,4580740,-21]]q_low=[[427150,4573253,-61],[419750,4569568,-51]]

- ${\left[29\right]}$:
- pp_up=[[425900,4572400,-4],[425900,4572200,-4],[425900,4572000,-4],[425900,4571800,-4],[425900,4571600,-4],[425700,4571600,-4],[425500,4571600,-4],[425900,4572400,-4],[426100,4572400,-4],[426300,4572400,-4],[426600,4572400,-4],[426900,4572400,-4],[425900,4572600,-4],[425900,4572800,-4],[425900,4573000,-4],[425900,4573200,-4],[425900,4573200,-4],[425700,4573200,-4],[425500,4573200,-4],[425300,4573200,-4],[425100,4573200,-4],[424900,4573200,-4],[425700,4573600,-4],[425700,4573800,-4],[425700,4574000,-4],[425700,4574200,-4],[425700,4574400,-4],[422850,4574505,0],[422850,4573785,0],[422850,4572385,0],[423540,4571069,0],[415604,4570100,-10],[415704,4570200,-10],[415804,4570250,-10],[415904,4570300,-10],[414600,4569700,-9],[414200,4569300,-9],[414100,4569100,-9],[413700,4568900,-15],[414400,4569500,-8],[414700,4569600,-7],[414800,4569900,-7],[415050,4570100,-7],[414650,4569700,-9],[414250,4569300,-9],[414150,4569100,-9],[413750,4568900,-15],[413800,4569100,-8],[413850,4569300,-10],[413850,4569120,-8],[413900,4569320,-10],[414450,4569500,-8],[414750,4569600,-7],[414850,4569900,-7],[415100,4570100,-7]]pp_mid=[[423200,4572114,-42],[423400,4572114,-42],[423600,4572114,-42],[423600,4572400,-42],[423600,4572800,-42],[423800,4572800,-42],[424000,4572800,-42],[424500,4573200,-42],[424800,4572300,-42],[425000,4572300,-42],[425200,4572700,-42],[425400,4572900,-42],[428622,4575033,-32],[428400,4575033,-32],[428200,4575033,-32],[428000,4575033,-32],[427800,4575033,-32],[427800,4575400,-32],[4279000,4575800,-32],[428000,4576500,-32],[428050,4576800,-32],[428000,4576000,-32],[428400,4577500,-32]]pp_low=[[42260,457170,-53]]

- ${\left[30\right]}$:
- qq_up=[[416530,4572240,-20],[416530,4572440,-20],[416530,4572640,-20],[416530,4572840,-20],[416730,4572840,-20],[416930,4572840,-20],[416230,4571940,-20],[415800,4571340,-20],[415200,4571340,-20],[421080,4579612,-9],[420900,4579700,-9],[420700,4579900,-9],[420500,4580100,-9],[420500,4580500,-9],[420500,4580700,-9],[420300,4580700,-9],[420100,4580700,-9],[420500,4580900,-9],[419100,4580300,-9],[419300,4580300,-9],[421000,4576555,-20],[420750,4576555,-20],[421300,4576555,-20],[420200,4576355,-20],[419100,4581200,-9],[419100,4581500,-9],[419100,4581700,-9],[418900,4581800,-9],[429190,4574600,-9]]qq_mid=[[422400,4574572,-40],[422200,4574572,-40],[422000,4574572,-40],[421900,4574572,-40],[421700,4574572,-40],[424985,4575950,-30],[424800,4575950,-30],[424600,4575950,-30],[424500,4575950,-30],[428209,4579026,-27],[428000,4579026,-27],[427800,4579026,-27],[427450,4579475,-27],[427450,4579300,-27],[427450,4579100,-27],[427450,4578900,-27],[426100,4575656,-27],[426250,4575656,-27],[426500,4575656,-27]]qq_low=[[423930,4571090,-61],[424100,4571090,-61],[424300,4571090,-61],[424500,4571090,-61],[424700,4571090,-61],[424900,4571090,-61],[428261,4574247,-68],[428161,4574247,-68],[428000,4574247,-68],[427100,4572800,-63],[426900,4572900,-63],[426700,4572900,-63],[417980,4570110,-55],[418100,4570110,-55],[418300,4570110,-55],[418500,4570110,-55],[418700,4570110,-55],[418900,4570110,-60],[419100,4570110,-60],[419300,4570110,-60],[419500,4570110,-60],[419700,4570110,-60],[423400,4570900,-56],[423600,4570900,-56],[423800,4570900,-56],[424000,4570900,-56],[425450,4573880,-58],[425650,4573880,-58],[425850,4573880,-58],[426050,4573880,-58],[426250,4573880,-58]]

- ${\left[31\right]}$:
- zxyzup_sands=np.vstack([zipxyzup_sands,pp_up])zxyzmid_sands=np.vstack([zipxyzmid_sands,pp_mid])zxyzlow_sands=np.vstack([zipxyzlow_sands,pp_low])

- ${\left[32\right]}$:
- zxyzup_gravels=np.vstack([zipxyzup_gravels,qq_up])zxyzmid_gravels=np.vstack([zipxyzmid_gravels,qq_mid])zxyzlow_gravels=np.vstack([zipxyzlow_gravels,qq_low])

- ${\left[33\right]}$:
- jup_0=grouping([p_up [0]],zxyzup_sands,275)jup_1=grouping([p_up [1]],zxyzup_sands,300)jup_2=grouping([p_up [2]],zxyzup_sands,275)jup_3=grouping([p_up [3]],zxyzup_sands,300)jup_4=grouping([p_up [4]],zxyzup_sands,300)jup_5=grouping([p_up [5]],zxyzup_sands,230)

- ${\left[34\right]}$:
- jup=[jup_0,jup_1,jup_2,jup_3,jup_4,jup_5]

- ${\left[35\right]}$:
- jmid_0=grouping([p_mid [0]],zxyzmid_sands,500)jmid_1=grouping([p_mid [1]],zxyzmid_sands,300)

- ${\left[36\right]}$:
- jmid=[jmid_0,jmid_1]

- ${\left[37\right]}$:
- jlow_0=grouping([p_low [0]],zxyzlow_sands,500)

- ${\left[38\right]}$:
- jlow=[jlow_0]

- ${\left[39\right]}$:
- kup_0=grouping([q_up [0]],zxyzup_gravels,550)kup_1=grouping([q_up [1]],zxyzup_gravels,400)kup_2=grouping([q_up [2]],zxyzup_gravels,350)kup_3=grouping([q_up [3]],zxyzup_gravels,350)kup_4=grouping([q_up [4]],zxyzup_gravels,350)

- ${\left[40\right]}$:
- kup=[kup_0,kup_1,kup_2,kup_3,kup_4]

- ${\left[41\right]}$:
- kmid_0=grouping([q_mid [0]],zxyzmid_gravels,300)kmid_1=grouping([q_mid [1]],zxyzmid_gravels,300)kmid_2=grouping([q_mid [2]],zxyzmid_gravels,500)kmid_3=grouping([q_mid [3]],zxyzmid_gravels,350)kmid_4=grouping([q_mid [4]],zxyzmid_gravels,700)

- ${\left[42\right]}$:
- kmid=[kmid_0,kmid_1,kmid_2,kmid_3,kmid_4]

- ${\left[43\right]}$:
- klow_0=grouping([q_low [0]],zxyzlow_gravels,700)klow_1=grouping([q_low [1]],zxyzlow_gravels,700)

- ${\left[44\right]}$:
- klow=[klow_0,klow_1]

- ${\left[45\right]}$:
- sands_up_hull=[ConvexHull(x) for x in jup]sands_mid_hull=[ConvexHull(x) for x in jmid] sands_low_hull=[ConvexHull(jlow_0)]

- ${\left[46\right]}$:
- gravels_up_hull=[ConvexHull(x) for x in kup] gravels_mid_hull=[ConvexHull(x) for x in kmid] gravels_low_hull=[ConvexHull(x) for x in klow]The function data_lit we defined uses the function Mesh3d by plotly.graph_objects to shape the data in a format easy to draw.

- ${\left[47\right]}$:
- gravels_up_names=[‘gr_up’+str(i) for i in range(len(gravels_up_hull))]gravels_mid_names=[‘gr_mid’+str(i) for i in range(len(gravels_mid_hull))]gravels_low_names=[‘gr_low’+str(i) for i in range(len(gravels_low_hull))]

- ${\left[48\right]}$:
- data_gravels_up=data_lit(gravels_up_hull,gravels_up_names,0,0.5,’lightblue’)data_gravels_mid=data_lit(gravels_mid_hull,gravels_mid_names,0,0.5,’lightblue’)data_gravels_low=data_lit(gravels_low_hull,gravels_low_names,0,0.5,’lightblue’)

- ${\left[49\right]}$:
- sands_up_names=[‘sd_up’+str(i) for i in range(len(sands_up_hull))] sands_mid_names=[‘sd_mid’+str(i) for i in range(len(sands_mid_hull))] sands_low_names=[‘sd_low’+str(i) for i in range(len(sands_low_hull))]data_sands_up=data_lit(sands_up_hull,sands_up_names,0,0.5,’yellow’)data_sands_mid=data_lit(sands_mid_hull,sands_mid_names,0,0.5,’yellow’)data_sands_low=data_lit(sands_low_hull,sands_low_names,0,0.5,’yellow’)

- ${\left[50\right]}$:
- lit_data=data_gravels_up + data_gravels_mid + data_gravels_low +data_sands_up + data_sands_mid + data_sands_low

- ${\left[51\right]}$:
- trigravels_up_names=[‘trgr_up’+str(i) for i in range(len(gravels_up_hull))]trigravels_mid_names=[‘trgr_mid’+str(i) for i in range(len(gravels_mid_hull))] trigravels_low_names=[‘trgr_low’+str(i) for i in range(len(gravels_low_hull))]trisands_up_names=[‘trsd_up’+str(i) for i in range(len(sands_up_hull))]trisands_mid_names=[‘trsd_mid’+str(i) for i in range(len(sands_mid_hull))]trisands_low_names=[‘trsd_low’+str(i) for i in range(len(sands_low_hull))]

- ${\left[52\right]}$:
- tdata_gravels_up=data_tri(gravels_up_hull,trigravels_up_names)tdata_gravels_mid=data_tri(gravels_mid_hull,trigravels_mid_names)tdata_gravels_low=data_tri(gravels_low_hull,trigravels_low_names)tdata_sands_up=data_tri(sands_up_hull,trisands_up_names)tdata_sands_mid=data_tri(sands_mid_hull,trisands_mid_names)tdata_sands_low=data_tri(sands_low_hull,trisands_low_names)

- ${\left[53\right]}$:
- tr_data=tdata_gravels_up + tdata_gravels_mid + tdata_gravels_low + tdata_sands_up + tdata_sands_mid + tdata_sands_lowWe can now define the Figure 3D_Lithosomes_LRD.html

- ${\left[54\right]}$:
- litosomes_data=lit_data+tr_data

- ${\left[55\right]}$:
- fig=go.Figure(data=litosomes_data)fig.add_trace(go.Scatter3d(x=xyzcontourn [0],y=xyzcontourn [1],z=xyzcontourn [2],mode=‘lines’,line_width=5,name=‘Delta Contour’,marker = dict(size = 4, color = ‘black’)))fig.update_layout( title=‘3D lithosomes Llobregat Delta, Z scale is x 50’,scene=dict(aspectratio=dict(x=2, y=2, z=0.5),xaxis = dict(range=[bound [0]-2000,bound [1]+2000],),yaxis = dict(range=[bound [2]-2000,bound [3]+2000])))#fig.show()go_offline.plot(fig,filename=FIGURESDIR+’3D_Lithosomes_LRD.html’,validate=True, auto_open=False)

#### Appendix A.4. The 3D Mapping of the Basement Top Surface: The 3D_Basement_LRD.Html File

- ${\left[56\right]}$:
- basement=pd.read_csv(DATADIR+’basement.csv’)Now we apply the function ’coordinates’ to extract the coordinates from the data.

- ${\left[57\right]}$:
- xyzbasement=coordinates(DATADIR+’basement.csv’,[1,2,3])The function nearby reduces de coordinates to those inside the delta contour.

- ${\left[58\right]}$:
- xyzbasement_near=nearby(xyzbasement,contourn_poly,500)We are going to adapt the bounds keeping in mind the bound given by the data in the basement, so first we apply the bounds function to the basement and then we use a new function bounds_join(b1,b2) which calculates new bounds of two lists of bounds.

- ${\left[59\right]}$:
- basement_bounds=bounds(xyzbasement)

- ${\left[60\right]}$:
- new_bounds=bounds_join(contourn_bounds,basement_bounds)We apply the interpolation.

- ${\left[61\right]}$:
- basement_itp=interpolation(xyzbasement,100,new_bounds)

- ${\left[62\right]}$:
- cbasement_itp=cutting(basement_itp,contourn_poly,500)

- ${\left[63\right]}$:
- xyzdat=coordinates(DATADIR+’boreholes.csv’,[1,2,3])xyzdat_near=nearby(xyzdat,contourn_poly,300)

- ${\left[64\right]}$:
- data_points=data_p([xyzdat_near,xyzbasement_near],[‘boreholes location’,’basement points’],[‘darkblue’,’red’],[‘cross’,’circle’],2)

- ${\left[65\right]}$:
- fig=go.Figure(data=data_points)fig.add_trace(go.Scatter3d(x=xyzcontourn [0],y=xyzcontourn [1],z=xyzcontourn [2],mode=‘lines’,line_width=5,name=‘Delta Contour’,marker = dict(size = 4, color = ‘black’)))fig.add_trace(go.Surface(z=cbasement_itp [0],x=cbasement_itp [1],y=cbasement_itp [2],opacity = 0.7,colorscale=‘brwnyl’,name=‘superficie basamento’,showscale=False))fig.update_layout( title=‘Pliocene basement Llobregat Delta, Z scale is x 50’,scene=dict(aspectratio=dict(x=2, y=2, z=0.5),xaxis = dict(range=[contourn_bounds [0]-2000,contourn_bounds [1]+2000],),yaxis = dict(range=[contourn_bounds [2]-2000,contourn_bounds [3]+2000])))#fig.show()go_offline.plot(fig,filename=FIGURESDIR+’3D_Basement_LRD.html’,validate=True, auto_open=False)

## References

- Custodio, E. Seawater intrusion in the Llobregat Delta near Barcelona (Catalonia, Spain). In Groundwater Problems in the Coastal Areas, Studies and Reports in Hydrology; UNESCO: Paris, France, 1987; Volume 45, pp. 436–463. [Google Scholar]
- Resolution 12956/1994. Cooperation agreement on infrastructure and environment in the Llobregat Delta. In Official Journal of Spain; Ministry of Public Works, Transports and Environment; Government of Spain: Madrid, Spain, 1994. Available online: https://www.boe.es/diario_boe/txt.php?id=BOE-A-1994-12956 (accessed on 18 April 2022).
- Official Statement. The water authority of catalonia creates the technical unit of the Llobregat Aquifers. In Official Journal of Catalonia; Department of the Environment and Housing, Government of Catalonia: Barcelona, Spain, 2004. Available online: https://govern.cat/salapremsa/notes-premsa/68710/agencia-catalana-aigua-crea-mesa-tecnica-dels-aqueifers-del-llobregat (accessed on 18 April 2022).
- Medialdea, J.; Solé-Sabarís, L. Geological Map of Spain, Scale 1:50,000, Sheet nº 420; Hospitalet de Llobregat, Memory and Maps, Geological Survey of Spain: Madrid, Spain, 1973; Available online: http://info.igme.es/cartografiadigital/geologica/Magna50Hoja.aspx?language=es&id=420 (accessed on 18 April 2022).
- Medialdea, J.; Solé-Sabarís, L. Geological Map of Spain, Scale 1:50,000, Sheet nº 448; El Prat de Llobregat, Memory and Maps, Geological Survey of Spain: Madrid, Spain, 1991; Available online: http://info.igme.es/cartografiadigital/geologica/Magna50Hoja.aspx?language=es&id=448 (accessed on 18 April 2022).
- Alonso, F.; Peón, A.; Rosell, J.; Arrufat, J.; Obrador, A. Geological Map of Spain, Scale 1:50,000, Sheet nº 421; Barcelona, Memory and Maps, Geological Survey of Spain: Madrid, Spain, 1974; Available online: http://info.igme.es/cartografiadigital/geologica/Magna50Hoja.aspx?language=es&id=421 (accessed on 18 April 2022).
- Gámez, D.; Simó, J.A.; Lobo, F.J.; Barnolas, A.; Carrera, J.; Vázquez-Suñé, E. Onshore–offshore correlation of the Llobregat deltaic system, Spain: Development of deltaic geometries under different relative sea-level and growth fault influences. Sediment. Geol.
**2009**, 217, 65–84. [Google Scholar] [CrossRef] - Almera, J. Mapa Geológico y Topográfico De La Provincia De Barcelona: Región Primera o De Contornos de la Capital Detallada, Scale 1:40,000, Memory and Maps, Diputación de Barcelona, Barcelona. 1891. Available online: https://cartotecadigital.icgc.cat/digital/collection/catalunya/id/2174 (accessed on 18 April 2022).
- Llopis, N. Tectomorfología del Macizo del Tibidabo y valle inferior del Llobregat. Estud. Geográficos
**1942**, 3, 321–383. [Google Scholar] - Solé-Sabarís, L. Ensayo de interpretación del Cuaternario Barcelonés. Misc. Barcinonensia
**1963**, 2, 7–54. [Google Scholar] - Marqués, M.A. Les Formacions Quaternàries del Delta del Llobregat; Institut d’Estudis Catalans: Barcelona, Spain, 1984. [Google Scholar]
- IGME. Geological Map of the Spanish Continental Shelf and Adjacent Areas, Scale 1:200,000, Sheet nº 42E; Barcelona, Memory and Maps, Geological Survey of Spain: Madrid, Spain, 1989; Available online: https://info.igme.es/cartografiadigital/tematica/Fomar200Hoja.aspx?language=es&id=42E (accessed on 18 April 2022).
- IGME. Geological Map of the Spanish Continental Shelf and Adjacent Areas, Scale 1:200,000, Sheet nº 42; Tarragona, Memory and Maps, Geological Survey of Spain: Madrid, Spain, 1986; Available online: https://info.igme.es/cartografiadigital/tematica/Fomar200Hoja.aspx?language=es&id=42 (accessed on 18 April 2022).
- Manzano, M. Estudio Sedimentológico del Prodelta Holoceno del Llobregat. Master’s Thesis, University of Barcelona, Barcelona, Spain, 1986. [Google Scholar]
- Serra, J.; Verdaguer, A. La plataforma holocena en el prodelta del Llobregat. In X Congreso Nacional de Sedimentología; Obrador, A., Ed.; University of Barcelona: Barcelona, Spain, 1983; Volume 2, pp. 49–51. [Google Scholar]
- Iribar, V.; Carrera, J.; Custodio, E.; Medina, A. Inverse modelling of seawater intrusion in the Llobregat delta deep aquifer. J. Hydrol.
**1997**, 198, 226–247. [Google Scholar] [CrossRef] - Alcalá-García, F.J.; Miró, J.; García-Ruz, A. Sobre la intrusión marina en el sector oriental del acuífero profundo del delta del Llobregat (Barcelona, España). Breve descripción histórica y evolución actual. Boletín Real Soc. Española Hist. Nat.
**2002**, 97, 42–49. [Google Scholar] - Alcalá-García, F.J.; Miró, J.; Rodríguez, P.; Rojas-Martín, I.; Martín-Martín, M. Actualización geológica del delta del Llobregat (Barcelona, España). Implicaciones geológicas e hidrogeológicas. In Tecnología de la Intrusión de Agua de Mar en Acuíferos Costeros: Países Mediterráneos; López-Geta, J.A., de la Orden, J.A., Gómez, J.D., Ramos, G., Mejías, M., Rodríguez, L., Eds.; Geological Survey of Spain: Madrid, Spain, 2003; Volume 1, pp. 45–52. [Google Scholar]
- Alcalá-García, F.J.; Miró, J.; Rodríguez, P.; Rojas-Martín, I.; Martín-Martín, M. Características estructurales y estratigráficas del substrato Plioceno del Delta de Llobregat (Barcelona, España). Aplicación a los estudios hidrogeológicos. Geo-Temas
**2003**, 5, 23–26. [Google Scholar] - Simó, J.A.; Gàmez, D.; Salvany, J.M.; Vàzquez-Suñé, E.; Carrera, J.; Barnolas, A.; Alcalá, F.J. Arquitectura de facies de los deltas cuaternarios del río Llobregat, Barcelona, España. Geogaceta
**2005**, 38, 171–174. [Google Scholar] - Jessell, M. Three-dimensional geological modelling of potential-field data. Comput. Geosci.
**2001**, 27, 455–465. [Google Scholar] [CrossRef] - Wycisk, P.; Hubert, T.; Gossel, W.; Neumann, C. High-resolution 3D spatial modelling of complex geological structures for an environmental risk assessment of abundant mining and industrial megasites. Comput. Geosci.
**2009**, 35, 165–182. [Google Scholar] [CrossRef] - Ford, J.; Mathers, S.; Royse, K.; Aldiss, D.; Morgan, D.J.R. Geological 3D modelling: Scientific discovery and enhanced understanding of the subsurface, with examples from the UK. Z. Der Dtsch. Ges. Fur Geowiss.
**2010**, 161, 205–218. [Google Scholar] [CrossRef] [Green Version] - Rohmer, O.; Bertrand, E.; Mercerat, E.D.; Régnier, J.; Pernoud, M.; Langlaude, P.; Alvarez, M. Combining borehole log-stratigraphies and ambient vibration data to build a 3D Model of the Lower Var Valley, Nice (France). Eng. Geol.
**2020**, 270, 105588. [Google Scholar] [CrossRef] - GeoPandas. Available online: https://geopandas.org/en/stable (accessed on 7 June 2022).
- GemPy: Open-Source 3D Geological Modeling. Available online: https://www.gempy.org (accessed on 7 June 2022).
- Albion: 3D Geological Models in QGIS. Available online: https://gitlab.com/Oslandia/albion (accessed on 7 June 2022).
- GISgeography. 15 Python Libraries for GIS and Mapping. Available online: https://gisgeography.com/python-libraries-gis-mapping (accessed on 7 June 2022).
- Parpoil, B. Open Source and Geology. Available online: https://oslandia.com/en/2020/07/09/geologie-open-source (accessed on 7 June 2022).
- Hobona, G.; James, P.; Fairbairn, D. Web-based visualization of 3D geospatial data using Java3D. IEEE Comput. Graph. Appl.
**2006**, 26, 28–33. Available online: https://ieeexplore.ieee.org/document/1652923 (accessed on 7 June 2022). [CrossRef] [PubMed] - Evangelidis, K.; Papadopoulos, T.; Papatheodorou, K.; Mastorokostas, P.; Hilas, C. 3D geospatial visualizations: Animation and motion effects on spatial objects. Comput. Geosci.
**2018**, 111, 200–212. [Google Scholar] [CrossRef] - Semmo, A.; Trapp, M.; Jobst, M.; Doellner, J. Cartography-oriented design of 3D geospatial information visualization–overview and techniques. Cartogr. J.
**2015**, 52, 95–106. [Google Scholar] [CrossRef] - Miao, R.; Song, J.; Zhu, Y. 3D geographic scenes visualization based on WebGL. In 6th International Conference on Agro-Geoinformatics; IEEE: Fairfax, VA, USA, 2017; Volume 1, pp. 1–6. Available online: https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=8046999 (accessed on 7 June 2022).
- Pyrcz, M. GeostatsGuy Lectures. Available online: https://www.youtube.com/c/GeostatsGuyLectures (accessed on 7 June 2022).
- MOP. Estudio de los Recursos Hidráulicos Totales de las Cuencas de los Ríos Besós y Bajo Llobregat; Ministerio de Obras Públicas, Centro de Estudios Hidrográficos: Madrid, Spain, 1966; Volumes 1–4. [Google Scholar]
- Font, J.; Julia, A.; Rovira, J.; Salat, J.; Sanchez-Pardo, J. Circulación marina en la plataforma continental del Ebro determinada a partir de la distribución de masas de agua y los microcontaminantes orgánicos en el sedimento. Acta Geol. Hisp.
**1987**, 21–22, 483–489. [Google Scholar] - Chiocci, F.L.; Ercilla, G.; Torres, J. Stratal architecture of Western Mediterranean Margins as the result of the stacking of Quaternary lowstand deposits below ‘glacio-eustatic fluctuation base-level’. Sediment. Geol.
**1997**, 112, 195–217. [Google Scholar] [CrossRef] - Python Programming Language. Available online: https://www.python.org (accessed on 7 June 2022).
- Pandas. Available online: https://pandas.pydata.org (accessed on 7 June 2022).
- Plotly. Available online: https://plotly.com (accessed on 7 June 2022).
- UTM. Available online: https://pypi.org/project/utm/ (accessed on 7 June 2022).
- Scipy. Available online: https://scipy.org (accessed on 7 June 2022).
- Alcalá, F.J.; Martín-Martín, M.; García-Ruz, A. A lithology database from historical 457 boreholes in the Llobregat River Delta aquifers in northeastern Spain. Figshare Dataset
**2020**. [Google Scholar] [CrossRef] - Convex Hull Algorithm. Available online: https://docs.scipy.org/doc/scipy/reference/generated/scipy.spatial.ConvexHull.html (accessed on 7 June 2022).
- Delaunay Triangulation Algorithm. Available online: https://docs.scipy.org/doc/scipy/reference/generated/scipy.spatial.Delaunay.html (accessed on 7 June 2022).
- GEODOSE. Available online: https://www.geodose.com/2019/09/3d-terrain-modelling-in-python.html (accessed on 7 June 2022).
- Parcerisa, D.; Gámez, D.; Gómez-Gras, D.; Usera, J.; Simó, J.A.; Carrera, J. Estratigrafía y petrología del subsuelo precuaternario del sector SW de la depresión de Barcelona (Cadenas Costeras Catalanas, NE de Iberia). Rev. Soc. Geológica España
**2008**, 21, 93–109. [Google Scholar]

**Figure 1.**Geological sketch map of the LRD area (red line contour), modified and updated from Medialdea and Solé-Sabarís [4,5], Alonso et al. [6], and Gámez et al. [7]. Geological cross-sections

**A**-

**A**’ and

**B**-

**B**’ are displayed in Figure 2. Geotechnical borehole SM P-4 with granulometry data are displayed in Figure 3.

**Figure 8.**The 3D distribution of the granulometry classes along the Z axis in each of the 433 compiled boreholes in the LRD. The plotting adopted a 1:1:50 (x = 2, y = 2 and z = 0.5) aspect ratio for better display. The color assigned to each granulometry class is cyan for gravel, yellow for coarse sand, gray for silt–clay, and red for the basement. An interactive 3D HTML version of this model is provided as supplementary material (3D_Boreholes_LRD.html).

**Figure 9.**Zenithal (

**A**), SE–NW frontal (

**B**), and NE–SW lateral (

**C**) views of the gravel (G) and coarse sand (S) lithosomes within the LRD lower (l), middle (m), and upper (u) intervals. The plotting adopted a 1:1:50 (x = 2, y = 2 and z = 0.5) aspect ratio for better display. The color assigned to each lithesome is cyan for gravel and yellow for coarse sand. An interactive 3D HTML version of this model is provided as supplementary material (3D_Lithosomes_LRD.html).

**Figure 10.**Zenithal (

**A**), SE–NW frontal (

**B**) and NE–SW lateral (

**C**) views of the LRD basement top surface. The plotting adopted a 1:1:50 (x = 2, y = 2 and z = 0.5) aspect ratio for better display. The brown scale varies from light to dark tones for the shallower and deeper basement occurrences, respectively. An interactive 3D HTML version of this model is provided as supplementary material (3D_Basement_LRD.html).

Publisher’s Note: MDPI stays neutral with regard to jurisdictional claims in published maps and institutional affiliations. |

© 2022 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).

## Share and Cite

**MDPI and ACS Style**

Bullejos, M.; Cabezas, D.; Martín-Martín, M.; Alcalá, F.J.
A Python Application for Visualizing the 3D Stratigraphic Architecture of the Onshore Llobregat River Delta in NE Spain. *Water* **2022**, *14*, 1882.
https://doi.org/10.3390/w14121882

**AMA Style**

Bullejos M, Cabezas D, Martín-Martín M, Alcalá FJ.
A Python Application for Visualizing the 3D Stratigraphic Architecture of the Onshore Llobregat River Delta in NE Spain. *Water*. 2022; 14(12):1882.
https://doi.org/10.3390/w14121882

**Chicago/Turabian Style**

Bullejos, Manuel, David Cabezas, Manuel Martín-Martín, and Francisco Javier Alcalá.
2022. "A Python Application for Visualizing the 3D Stratigraphic Architecture of the Onshore Llobregat River Delta in NE Spain" *Water* 14, no. 12: 1882.
https://doi.org/10.3390/w14121882