Introduction to
openEO develops an open API to connect R, Python,
JavaScript and other clients to big Earth observation
cloud back-ends in a simple and unified way.
console
tab
// Variables are used to store objects, and are defined
// using the keyword var.
var the_answer = 42;
// String objects start and end with double quotes.
var my_variable = "I am a string";
// there are other ways to delare variables in js
let the_answer = 42;
const the_answer = 42;
// we will ignore these
// Statements *should* end in a semi-colon
var test = 'I feel incomplete...'
var test = 'I feel complete...';
.html
script
tag
myname
with your namemyage
with your agemyage_days
Hi, my name is ... and I am ... days old
years2days
// this is the syntax for creating a function:
function say_something(what){
console.log(what)
};
// Line comments start with two forward slashes.
// Like this line.
/*
Multi line comments start with a forward slash
and a star,
and end with a star and a forward slash.
*/
// Parentheses are used to pass parameters to functions.
// the function below is console.log
console.log("this is the parameter");
// Square brackets are used to create a list of items
var my_list = ['eggplant', 'apple', 'wheat'];
// Square brackets are also used for selecting items within
// a list. 0 refers to the first item in the list.
my_list[0];
// Curly brackets are used to define "dictionaries"
var my_dict = {'food':'bread', 'color':'red', 'number':42};
// Square brackets are used to access items (by key).
my_dict['color'];
// Or you can use the dot notation to get the same result.
my_dict.color;
// Functions can be defined as a way to reuse code and
// make it easier to read.
function years2days(years){
return years*365
};
years2days(34);
// Functions can be defined as a way to reuse code and
// make it easier to read.
var say_hello = function(string) {
return 'Hello ' + string + '!';
};
say_hello('world');
Javascript is part of a trinity that defines most of the web
Let's take this opportunity to explore and understand this.
(Demo time)
Create an application that takes your name as an input and returns the name backwards.
Tipp: use the methods split
, reverse
and join
.
Instructions
(note: all code will be shared)
Importing Data
(hit Ctr + Enter to run the script)
var srtm = ee.Image("USGS/SRTMGL1_003")
Importing Data
(hit Ctr + Enter to run the script)
var srtm = ee.Image("USGS/SRTMGL1_003")
console.log(srtm)
Importing Data
(hit Ctr + Enter to run the script)
var srtm = ee.Image("USGS/SRTMGL1_003")
console.log(srtm)
Map.addLayer(srtm);
Importing Data
(hit Ctr + Enter to run the script)
var srtm = ee.Image("USGS/SRTMGL1_003")
console.log(srtm)
Map.addLayer(
srtm
);
Importing Data
(hit Ctr + Enter to run the script)
var srtm = ee.Image("USGS/SRTMGL1_003")
console.log(srtm)
Map.addLayer(
srtm,
{min:0, max:3000} // min & max elevation vals
);
Importing Data
(hit Ctr + Enter to run the script)
var srtm = ee.Image("USGS/SRTMGL1_003")
console.log(srtm)
Map.addLayer(
srtm,
{min:0, max:3000} // min & max elevation vals
palette: "blue, yellow, red" // or your own colours
);