Simple topographic grid generation

In this notebook, we will see how to generate a regular topographic grid for generic cases based on 3 simple geometrical forms:

Combining these simple forms it is possible to create some complex geometries that will have the desired format for running a badlands simulation.

Badlands imports a regular grid that is later triangularized and used to compute erosion and deposition induced by a combination of climate, tectonics and sea-level changes.


In [1]:
%matplotlib inline

# Import badlands grid generation toolbox
import pybadlands_companion.toolGeo as simple

# display plots in SVG format
%config InlineBackend.figure_format = 'svg'


1. Building a regular surface

We first initialize the extent of the simulation area.

The function takes 3 arguments:

  • the extent of the domain along the X-axis [xmin,xmax] in metres,
  • the extent of the domain along the Y-axis [ymin,ymax] in metres,
  • the grid spacing dx in metres.

For more information regarding the function uncomment the following cell.


In [2]:
#help(simple.toolGeo.__init__)

In [3]:
slope = simple.toolGeo(extentX=[0.,40000.], extentY=[0.,40000.], dx=200.)

2. Constant slope

The slope function takes 3 parameters:

  • the initial base of the elevation in metres,
  • the slope (as dz/dx)
  • the direction of the slope: either along the X or Y axis

For more information regarding the function uncomment the following cell.


In [4]:
#help(slope.buildSlope)

In [26]:
slope.Z = slope.buildSlope(base=0.,slope=0.0, axis='X')

It is possible to have a look at the grid surface using plotly library before proceeding to the creation of the badlands surface.


In [27]:
#help(slope.viewGrid)

In [28]:
slope.viewGrid(width=600, height=600, zmin=0, zmax=1000, zData=slope.Z, title='Export Slope Grid')


Once the surface has been generated, we export a CSV regular grid that will be loaded in the simulation. The file provides for each line the following information:

  • X coordinates in meters (this axis has a West to East orientation),
  • Y coordinates in meters (this axis has a South to West orientation),
  • Z coordinates in meters.

Note: Nodes must be defined in increasing order from the South/West corner, first along the X axis.

The buildGrid function takes the return elevation from the buildSlope function and creates the badlands grid in the appropriate format.

For more information regarding the function uncomment the following cell.


In [29]:
#help(slope.buildGrid)

In [30]:
slope.buildGrid(elevation=slope.Z, nameCSV='mountain/data/slope200')

3. Sine surface

Now, we move to another surface generation model based on a cosine wave.

Here again, we first initialize the extent of the simulation area.

The function takes 3 arguments:

  • the extent of the domain along the X-axis [xmin,xmax] in metres,
  • the extent of the domain along the Y-axis [ymin,ymax] in metres,
  • the grid spacing dx in metres.

For more information regarding the function uncomment the following cell.


In [10]:
#help(simple.toolGeo.__init__)

In [11]:
wave = simple.toolGeo(extentX=[0.,50000.], extentY=[0.,50000.], dx=100.)

We create a wave by defining 3 parameters:

  • the amplitude of the wave: A in metres,
  • the period of the wave: P in metres,
  • the baselevel of the simulatin grid,
  • the center of the wave along the X-axis.

For more information regarding the function uncomment the following cell.


In [12]:
#help(wave.buildWave)

In [13]:
wave.Z = wave.buildWave(A=250., P=20000., base=100., xcenter=25000.)

It is possible to have a look at the grid surface using plotly library before proceeding to the creation of the badlands surface.


In [14]:
#help(wave.viewGrid)

In [15]:
wave.viewGrid(width=600, height=600, zmin=-1000, zmax=1000, zData=wave.Z, title='Export Wave Grid')


Once the surface has been generated, we export a CSV regular grid that will be loaded in the simulation. The file provides for each line the following information:

  • X coordinates in meters (this axis has a West to East orientation),
  • Y coordinates in meters (this axis has a South to West orientation),
  • Z coordinates in meters.

Note: Nodes must be defined in increasing order from the South/West corner, first along the X axis.

The buildGrid function takes the return elevation from the buildWave function and creates the badlands grid in the appropriate format.

For more information regarding the function uncomment the following cell.


In [16]:
#help(wave.buildGrid)

In [17]:
wave.buildGrid(elevation=wave.Z, nameCSV='xyz')

4. Half-ellipsoid surface

The last example show how to create a half-ellipsoid (dome-shape) surface. The ellipsoid equation center on ($x_o,y_o,z_o$) is of the form:

$$ \frac{(x-x_o)^2}{a^2} + \frac{(y-y_o)^2}{b^2} + \frac{(z-z_o)^2}{c^2} = 1 $$

where $a,b,c$ are strictly positives and equal to the lenght of the ellipsoid half axes.

Here again, we first initialize the extent of the simulation area.

The function takes 3 arguments:

  • the extent of the domain along the X-axis [xmin,xmax] in metres,
  • the extent of the domain along the Y-axis [ymin,ymax] in metres,
  • the grid spacing dx in metres.

For more information regarding the function uncomment the following cell.


In [18]:
#help(simple.toolGeo.__init__)

In [19]:
dome = simple.toolGeo(extentX=[0.,50000.], extentY=[0.,50000.], dx=100.)

We create the dome wave by defining 6 parameters:

  • the ellipsoif half axes: {a,b,c} in metres,
  • the baselevel of the simulatin grid ($z_o$) in metres,
  • the center of the dome {x,y} coordinates in metres.

The function buildDome solves for the given parameters the following equation for the elevation:

$$ z = z_o + c \sqrt{1 - \frac{(x-x_o)^2}{a^2} -\frac{(y-y_o)^2}{b^2} } $$

For more information regarding the function uncomment the following cell.


In [20]:
#help(dome.buildDome)

In [21]:
dome.Z = dome.buildDome(a=10000., b=20000., c=500., base=100., xcenter=25000., ycenter=25000.)

It is possible to have a look at the grid surface using plotly library before proceeding to the creation of the badlands surface.


In [22]:
#help(dome.viewGrid)

In [23]:
dome.viewGrid(width=600, height=600, zmin=-1000, zmax=1000, zData=dome.Z, title='Export Dome Grid')


Once the surface has been generated, we export a CSV regular grid that will be loaded in the simulation. The file provides for each line the following information:

  • X coordinates in meters (this axis has a West to East orientation),
  • Y coordinates in meters (this axis has a South to West orientation),
  • Z coordinates in meters.

Note: Nodes must be defined in increasing order from the South/West corner, first along the X axis.

The buildGrid function takes the return elevation from the buildDome function and creates the badlands grid in the appropriate format.

For more information regarding the function uncomment the following cell.


In [24]:
#help(dome.buildGrid)

In [25]:
dome.buildGrid(elevation=dome.Z, nameCSV='xyz')

In [ ]: