In this post, we will extract the seismic binary data into a vanilla Spotfire table which we can visualize using a heatmap.  In the next post, we will actually do some interpretation on the seismic, but for now we wanted to show how you can manipulate seismic data in TERR.  We will add some dynamic interaction so the user can select different cross line or inline indices to extract and view in a heatmap.  Once the data is extracted and visualized, we can color it, mark it, and build histograms with it.  Ok let’s get started.

Seismic is a powerful data format for upstream oil and gas workflows, and in this series of posts we are exploring how we can effectively leverage it within Spotfire and build novel, flexible workflows.  In a previous post we talked about loading seismic in using the 3D Subsurface visualization, and now we are going to show how we can manipulate the seismic values within TERR.  Because TERR runs the R language, we have access to countless statistics and analytic packages developed by the community.  This includes, if you are familiar with seismic, cool packages like FFT and other time series functionality.  There are also packages not available in current seismic interpretation software like genetic algorithms, flexible image processing, and machine learning.

Loading in Seismic

Let’s start by loading in some 3D seismic stored in a Segy file. To do this in Spotfire, you’ll need the 3D subsurface visualization. There are other ways to bringing this data in, for instance using TIBCO OpenSpirit.

3D seismic is a lot like 2D seismic but has vertical traces across a two dimensional space rather than along a line. If you plot the X and Y columns of the data table, you’ll get something that should look like a grid. The grid may be shifted in XY space, but should have uniform structure. I’ve loaded in Teapot Dome data, and it looks something like this.

Sending Seismic to a Data Function

Now, let’s create a data function that extracts the seismic values from trace data. Our function will take in a set of trace rows (masked my marking or filtering) and repeat the trace header data for each value in the trace array. So, create a data function that takes as input the seismic data table and limit it to a given marking.

I created a cross table that listed the crossline indices that I could easily then mark to send to the data function. You could use any other Spotfire visualization to set the marking instead.

Within the TERR function, we need to parse the binary float array into values that we can manipulate. R gives us a lot of binary reading and writing functionality with the ‘readBin’ and ‘writeBin’ functions. In this case, we want to read the floats out of the binary array:

vals = readBin(...)

Our ‘vals’ array now holds the float values themselves in a format that we can send back to Spotfire as Reals. So, we just need to merge this array of floats with the trace header data using the ‘merge’ function.

We then send this back to Spotfire as the resulting value of the data function. Altogether, the function looks like this:

# Simple function for unpacking the binary into a float array
read.floats <- function(data) {
  conn = rawConnection( data )
  # floats are 4 bytes
  num = length(data)/4;
  values = readBin( conn, "double", size=4, n=num);

Seismic$MinValue = rep(NA, nrow(Seismic))
Seismic$Row = 1:nrow(Seismic)
# Our result vectors
all_values = c()
vrows = c()
indices = c()
for( i in 1:nrow(Seismic) ) {
   data = as.raw(Seismic[['VALUES']][[i]])
   values = read.floats( data );
   all_values = c( all_values, values)
   vrows = c( vrows, rep(i, length(values)) )
   indices = c(indices, 1:length(values))

dfvals = data.frame(Value=all_values, Row=vrows, Index=indices)

Result = merge(Seismic[,c("TRACENO","FFID","SOU_X","SOU_Y","XLINE_NO","INLINE_NO","Row")], dfvals)

And Voila! We now have seismic values extracted from the binary. I can create a heatmap of these values to recreate the seismic cross section for the slice I marked earlier. If we set this function to run automatically, then the slices will update as the user clicks on different crosslines!

With the seismic trace data in the heatmap, we can color it based on rules (say if we wanted to show different lithologies) or look at correlations between depth and frequency of certain amplitudes. It’s just tabular data at this point, so any Spotfire visualization can consume and visualize it.

I went ahead and created a histogram of amplitude values. I can mark the tails to see where they show up on the slice itself.
You can grab this analysis over at In the next post, we are going to actually interpret the seismic data by writing back to the binary array and visualizing it in Spotfire. In the next post we will actually write back to the seismic data so we can see our “intepretations” in 3D.

To do this at home (or at work), you can get access to our seismic viewer analysis here. You will need Spotfire and the 3D Subsurface Visualization if you want to load in other Segy files.

Written by Troy Ruths
You'll conquer the present suspiciously fast if you smell of the future....and stink of the past.