Developers Corner

How to Store and Retrieve Well Log Rasters in Spotfire using

Recently I was asked, “Can I store the original raster files alongside well logs in”. The answer is yes! And they can be paired with the Well Log and visualized in Spotfire.

This involves a couple steps:

  1. How are raster files stored in
  2. How are they inserted into the system?
  3. How are they retrieved in something like Spotfire?

We”ll tackle all three of these questions.


While stores binary types in its schema, the easiest way to insert files into your documents is through base64 encoding. This means that the image is converted into a string which is a whole lot easier to insert into a database. Since we’re inserting well logs, let’s look at the schema.

	"logType": 0,
	"version": null,
	"wrap": false,
	"pwi": "5d07e055a5e755136c4e5e97",
	"wellApi": null,
	"wellUwi": null,
	"wellId": "49035237990000",
	"wellName": null,
	"depthStart": null,
	"depthStop": null,
	"depthUnits": null,
	"timeStart": null,
	"timeStop": null,
	"start": null,
	"stop": null,
	"step": 0,
	"nullValue": null,
	"company": null,
	"field": null,
	"province": null,
	"state": null,
	"country": null,
	"county": null,
	"location": null,
	"serviceCompany": null,
	"logDate": null,
	"licenseNumber": null,
	"pointCount": null,
	"curves": {},
	"curveNames": "",
	"parameters": {},
	"parameterNames": "",
	"comments": null,
	"sourceFileName": null,
	"sourceFileUri": null,
	"sourceHash": null,
	"id": "5d0920b8fd036714f02faa8b",
	"createdAt": "2019-06-18T17:34:48.575Z",
	"createdBy": null,
	"updatedAt": "2019-06-18T17:34:48.575Z",
	"updatedBy": null,
	"deletedBy": null,
	"deletedAt": null,
	"isDeleted": false,
	"schemaVersion": "1.0.0",
	"createdActivityId": "5d0920b8fd036714f02faa8a",
	"lastUpdatedActivityId": "5d0920b8fd036714f02faa8a"
"extra": {}

Normally, the curves would go into the curves object and then when brought into Spotfire, would unpack into a table with depth as it’s spine. But we need to add a picture!

Here’s what the encoding does, consider this tag that references a file.

<img src="example.png">

Encoding it replaces the reference with the actual data of the picture, in the form of text.

<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZAAAADSCAMAAABThmYtAAAAXVB">

Using Python or another encoder, you can take a well log image and convert it into the base64 encoding. Remember this may be enormous!

Loading Encoded Raster Well Logs

Now using the above encoding, we’ll import a new Well Log document that doesn’t have digital curves but rather a static image. We won’t be able to use the jobs manager for this, instead we’ll be using the API. The API will allow us to interact with the well log collection easily:

We’ll use Python to make this happen:

import os
import requests
from pprint import pprint
import datetime

PETRO_URL = 'https://&amp;amp;amp;lt;&amp;amp;amp;lt;YOUR PETRO.AI SERVER&amp;amp;amp;gt;&amp;amp;amp;gt;/api/WellLogs'
wellId = '5d07e055a5e755136c4e5e97'

def post_well_log_raster(endpoint, identifier, raster):
    data = {
        "data": [
                "pwi": identifier,
                "extra": {
                    "raster": raster

    r =, json=data)
    print('REQUEST STATUS: ', r.status_code)
    if r.status_code == 400 or r.status_code == 404:
        raise requests.RequestException(r)
    return r.json()

post_well_log_raster(PETRO_URL, wellId, raster)

This should return a REQUEST STATUS: 200 that your well log has been inserted! Let’s take a look in the data browser:

Let’s see some curves!

Now we can use the Petro Panel inside Spotfire to retrieve the rasters! Spotfire has some handling for base64 encoded binaries, which you could use, but we’ll roll our own here.

First let’s pull down the Well Log collection:

This was done in Spotfire 7.14, but for you 10’ers out there, you’d go Tools > Petro Panel and then select Actions > Add Actions > Get Well Log.

Now when you load the well logs, don’t forget to add “Load Extra”, this brings in the raster object we added to the document to store the encoded image.

Spotfire will decode that for you using Calculated Expressions as shown here:


You can adjust the height of the row using the Data rows height:

That’s pretty good! However, I’d like something bigger and more dynamic.

Final Products

I’d like something that would be more dynamic so I can see the whole log by itself. I created a text area that will use a calculated value and pull in the raster into a full screen mode:

Big difference!

Alright well that’s all for today. If you have any questions feel free to reach out!



Leave a Reply

Your email address will not be published. Required fields are marked *