Getting Started
Render Sentinel 2 imagery
Export an image
Data Repository (data as a service)
Software as a Service (SaaS)
Platform as a service (PaaS)
is an interactive front-end scripting language
Statements - individual instruction or steps
statements end with a ;
Comments - explains what code does
// Displays a map
JavaScript is case sensitive
Variable - tell the system to remember or store data or a value
First Declare a variable
Then assign a value to a variable
Let's try some simple examples
Add Data and show it on the map
cut and paste this code into your code window
//call dataset with GPP
var dataset = ee.ImageCollection('MODIS/061/MOD17A2H')
.filter(ee.Filter.date('2021-01-01', '2021-05-01'));
//call only GPP
var gpp = dataset.select('Gpp');
//Visualize the GPP
var gppVis = {
min: 0,
max: 600,
palette: ['bbe029', '0a9501', '074b03'],
};
//center map
Map.setCenter(6.746, 46.529, 2);
//render the GPP data
Map.addLayer(gpp, gppVis, 'GPP');
print(gpp)
set the geometry manually - draw the box
in the map interface and adjust the transparency - then hit run
Then Click anywhere in your map
just to explore
Change the date ranges
// Export the sentinel 2 image to your google drive - name the image the location and date you selected in your code
Export.image.toDrive({
image: S2_mosaic,region: geometry,
description: 'UtrechtMayJune2018',
scale: 30,
//call sentinel 2 images specify date and cloud filter
var S2_collection = ee.ImageCollection("COPERNICUS/S2")
.filterBounds(geometry)
.filterDate('2018-05-01', '2018-06-14')
.filterMetadata('CLOUDY_PIXEL_PERCENTAGE', 'less_than', 10);
//what bands to make visible in the map below - clip only the imagery within the specific geometry or box you set
var S2_mosaic = S2_collection.median().clip(geometry);
var S2_display = {bands: ['B4', 'B3', 'B2'], min: 0, max: 3000};
//show the data on the map
Map.addLayer(S2_mosaic, S2_display, "Sentinel-2");
//center the map on the point of interest defined
Map.centerObject(geometry);
// Export the sentinel 2 image
Export.image.toDrive({
image: S2_mosaic,region: geometry,
description: 'UtrechtMayJune2018',
scale: 30,
});
//baked in geo
var geometry =
/* color: #d63000 */
/* shown: false */
/* displayProperties: [
{
"type": "rectangle"
}
] */
ee.Geometry.Polygon(
[[[5.058019540799301, 52.15382123004126],
[5.058019540799301, 51.96383817630241],
[5.395505807889145, 51.96383817630241],
[5.395505807889145, 52.15382123004126]]], null, false);
//call sentinel 2 images specify date
var S2_collection = ee.ImageCollection("COPERNICUS/S2")
.filterBounds(geometry)
.filterDate('2018-05-01', '2018-06-14')
.filterMetadata('CLOUDY_PIXEL_PERCENTAGE', 'less_than', 10);
//what bands to make visible in the map below - clip only the imagery within the specific geometry or box you set
var S2_mosaic = S2_collection.median().clip(geometry);
var S2_display = {bands: ['B4', 'B3', 'B2'], min: 0, max: 3000};
//show the data on the map
Map.addLayer(S2_mosaic, S2_display, "Sentinel-2");
//center the map on the point of interest defined
Map.centerObject(geometry);
// Export the sentinel 2 image
Export.image.toDrive({
image: S2_mosaic,region: geometry,
description: 'UtrechtMayJune2018',
scale: 30,
});
To export the image