Skip to content

Demo calculation spatial interpolation

This tutorial shows how to develop a simple calculation and deploy it to Nexus so that it can run real time on the incoming data stream.

Info

This tutorial assumes that you have:

  • Python installed on your computer
  • Docker Desktop installed on your computer
  • a Nexus account with Expert privileges

Let's develop a simple calculation in Python

Instead of starting from scratch, we're going to use a simple code already developed for you as an example. Download the demo code here and unzip the file on your computer.

Open a command prompt or terminal and navigate to the directory where you unzipped the file. Then install required packages:

pip install -r requirements.txt

Next, open your favorite code editor and edit the file config.py. Enter the developer credentials you received by email for variables DB_USER, DB_PASSWORD and WEB_API_TOKEN.

Then inspect the file called main.py. What's happening here is that we fetch for each weather station the precipitation sum for the current year, after which this sum is interpolated between the weather stations' locations using the 'inverse distance' algorithm. This operation produces a raster in a Geotiff file, which we upload to Nexus Datastore for storage and visualization.

Deploy it to Nexus

If we want to run this calculation every day, using the latest meteorological measurements, we should deploy the calculation to Nexus.

To deploy your calculation, open a command prompt or terminal and make sure you are navigated to the calculation directory. Then execute the following command:

deploy demo_interpolation {web_api_token}
Docker will start building your container and upload the container image to Nexus.

Run it in the cloud

When the calculation is ready and deployed for operational use, email StellaSpark to activate it and have it executed every time the input data changes or on a fixed timed interval (for example every day, every hour or whatever fits your need).