Class: Builder

Builder(processes, parent, id)

A class to construct processes easily.

An example (con is a object of type Connection):

var builder = await con.buildProcess();

var datacube = builder.load_collection(
  new Parameter("collection-id", "string", "The ID of the collection to load"), // collection-id is then a process parameter that can be specified by users.
  { "west": 16.1, "east": 16.6, "north": 48.6, "south": 47.2 },
  ["2018-01-01", "2018-02-01"],
  ["B02", "B04", "B08"]
);

// Alternative 1 - using the Formula class
var eviAlgorithm = new Formula('2.5 * (($B08 - $B04) / (1 + $B08 + 6 * $B04 + -7.5 * $B02))');
// Alternative 2 - "by hand"
var eviAlgorithm = function(data) {
  var nir = data["B08"]; // Array access by label, accessing label "B08" here
  var red = data["B04"];
  var blue = data["B02"];
  return this.multiply(
    2.5,
    this.divide(
      this.subtract(nir, red),
      this.sum([
        1,
        nir,
        this.multiply(6, red),
        this.multiply(-7.5, blue)
      ])
    )
  );
};
datacube = builder.reduce_dimension(datacube, eviAlgorithm, "bands")
                  .description("Compute the EVI. Formula: 2.5 * (NIR - RED) / (1 + NIR + 6*RED + -7.5*BLUE)");
                  
var min = function(data) { return this.min(data); };
datacube = builder.reduce_dimension(datacube, min, "t");

datacube = builder.save_result(datacube, "PNG");

var storedProcess = await con.setUserProcess("evi", datacube);

Constructor

new Builder(processes, parent, id)

Creates a Builder instance.

Each process passed to the constructor is made available as object method.

Parameters:
Name Type Default Description
processes array | object

Either an array containing processes or an object compatible with GET /processes of the API.

parent Builder | null null

The parent builder, usually only used by the Builder itself.

id string

A unique identifier for the process.

Source:

Methods

(async, static) fromURL(version) → {Builder}

Creates a Builder instance that can be used without connecting to a back-end.

It requests the processes for the version specified from the given URL. CORS needs to be implemented on the server-side for the URL given.

Parameters:
Name Type Description
version string | null
Source:
Throws:
Error
Returns:
Type
Builder

(async, static) fromVersion(version) → {Builder}

Creates a Builder instance that can be used without connecting to a back-end.

It requests the processes for the version specified from processes.openeo.org. Requests the latest version if no version number is passed.

Parameters:
Name Type Default Description
version string | null null
Source:
Throws:
Error
Returns:
Type
Builder

math(formula) → {BuilderNode}

Adds a mathematical formula to the process.

See the Formula class for more information.

Parameters:
Name Type Description
formula string
Source:
Throws:
Error
Returns:
Type
BuilderNode

process(processId, args, description) → {BuilderNode}

Adds another process call to the process chain.

Parameters:
Name Type Default Description
processId string

The id of the process to call.

args object | array

The arguments as key-value pairs or as array. For objects, they keys must be the parameter names and the values must be the arguments. For arrays, arguments must be specified in the same order as in the corresponding process.

description string | null null

An optional description for the process call.

Source:
Returns:
Type
BuilderNode