This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
Google Earth Engine is a cloud-based platform for planetary-scale geospatial analysis using a multi-petabyte catalogue of satellite imagery, geospatial datasets and huge computational capabilities of the Google LLC enterprise allowing besides other purposes for scientific researches and analysis regarding important societal issues such as deforestation, desertification, drought, disease, food security, changes in water levels or surface area, climate change and environmental protection.
Google Earth Engine enables users to compute on petabytes of data on the fly without having to navigate through the complexities of cloud computing and cloud-based programming. The programming is done via the Google Earth Engine JavaScript API and allows users to run algorithms on georeferenced satellite imagery and vectors which are stored within the cloud. The Google Earth Engine API also provides a library with a variety of functions and commands and a public data catalogue which contains many pre-processed datasets that can be used for further analysis. The actual programming is done in the Code Editor whose central component is a JavaScript editor which is an interactive environment for developing Earth Engine applications
JavaScript is a programming language that allows dynamic content updates, animated images and is alongside with HTML and CSS one of the core technologies of the Word Wide Web. It is a high-level language which means that the level of abstraction is high, it is often used for just-in-time compilation and is considered to be multi-paradigm programming language since it supports event-driven, functional and imperative programming styles. Originally JavaScript was developed in 1995 from Netscape for dynamic HTML in web browsers, but is now increasingly used for other software systems such as servers and a variety of applications such as the JavaScript API in the Google Earth Engine.
In order to analyse the water surface area changes over time different approaches to access the desired data from satellite imagery were tried. It is necessary to mention at this point that the following scripts and codes were created in an educational context with the aim to study remote sensing, satellite imagery analysis and JavaScript in the Google Earth Engine Editor and are due to the circumstances neither complete nor correct and some problems could not be solved in this work. In this context please find and run a generated script for calculating the NDVI (Normalized Differences Vegetation Index)in the Aral Lake area here.
Since the code folding for JavaScript did not work the code was implemented as R code which is responsible for the wrong highlighting.
hallo
hallo
For the calculations and visualizations for water occurrence and transition classes the JRC Global Surface Water Mapping Layers v1.0 data set was used. This data set contains information about the spatial and temporal distribution of surface water in the time period from 1984 - 2015. These data were generated using scenes from the landsat 5, 7, and 8 satellite which were recorded between 16th March 1984 and 10th October 2015. A classification of each pixel into water or non-water has already been applied using an expert system which produced a monthly history in surface water change for the entire time period stored different information in several bands. This approach contains the setting of appropriate visualization parameters, selection of desired information as bands (water occurrence, change intensity and transition class), creating a function that creates a feature for the transition classes in the respective area, create a JSON dictionary that defines the pie chart colours based on the transition class palette, creating a dictionary with the pie chart names and colours, generating a histogram that shows the occurrence of changes in surface water area, adding the pie chart with the transition classes to the console and adding the maps with the water occurrence and water pixels with a 90% threshold in occurrence, the water change intensity and the water transition. The maps where then exported as GeoTIFF files and implemented in this report. ALso a filtering process to define different time periods and display the possible differences was attempted. Find and run the following script in the Google Earth Engine Code Editor here.
Since the code folding for JavaScript did not work the code was implemented as R code which is responsible for the wrong highlighting.
///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////
//Water Surface Area of the Aral Lake//////////////////////////
///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////
//import dataset//
///////////////////////////////////////////////////////////////
var gsw = ee.Image('JRC/GSW1_0/GlobalSurfaceWater');
print(gsw, 'gsw');
var roi =
/* color: #98ff00 */
/* shown: false */
/* displayProperties: [
{
"type": "rectangle"
}
] */
ee.Geometry.Polygon(
[[[57.91985937500002, 46.93522519500926],
[57.91985937500002, 43.707555725336775],
[62.27044531250002, 43.707555725336775],
[62.27044531250002, 46.93522519500926]]], null, false);
///////////////////////////////////////////////////////////////
//select Layer//
///////////////////////////////////////////////////////////////
var occurrence = gsw.select('occurrence').clip(roi);
var change = gsw.select("change_abs").clip(roi);
var transition = gsw.select('transition').clip(roi);
print(transition, 'transition');
///////////////////////////////////////////////////////////////
//set styling parameters//
///////////////////////////////////////////////////////////////
var VIS_OCCURRENCE = {
min:0,
max:100,
palette: ['red', 'blue']
};
var VIS_CHANGE = {
min:-50,
max:50,
palette: ['red', 'black', 'limegreen']
};
var VIS_WATER_MASK = {
palette: ['white', 'black']
};
//////////////////////////////////////////////////////////////
//helper functions//
//////////////////////////////////////////////////////////////
// Create a feature for a transition class that includes the area covered.
function createFeature(transition_class_stats) {
transition_class_stats = ee.Dictionary(transition_class_stats);
var class_number = transition_class_stats.get('transition_class_value');
var result = {
transition_class_number: class_number,
transition_class_name: lookup_names.get(class_number),
transition_class_palette: lookup_palette.get(class_number),
area_m2: transition_class_stats.get('sum')
};
return ee.Feature(null, result); // Creates a feature without a geometry.
}
// Create a JSON dictionary that defines piechart colors based on the
// transition class palette.
// https://developers.google.com/chart/interactive/docs/gallery/piechart
function createPieChartSliceDictionary(fc) {
return ee.List(fc.aggregate_array("transition_class_palette"))
.map(function(p) { return {'color': p}; }).getInfo();
}
//////////////////////////////////////////////////////////////
//calculations//
//////////////////////////////////////////////////////////////
// Create a dictionary for looking up names of transition classes.
var lookup_names = ee.Dictionary.fromLists(
ee.List(gsw.get('transition_class_values')).map(ee.String),
gsw.get('transition_class_names')
);
// Create a dictionary for looking up colors of transition classes.
var lookup_palette = ee.Dictionary.fromLists(
ee.List(gsw.get('transition_class_values')).map(ee.String),
gsw.get('transition_class_palette')
);
// Create a water mask layer, and set the image mask so that non-water areas
// are transparent.
var water_mask = occurrence.gt(90).mask(1);
// Generate a histogram object and print it to the console tab.
var histogram = ui.Chart.image.histogram({
image: change,
region: roi,
scale: 30,
minBucketWidth: 10,
maxPixels: 1e9
});
histogram.setOptions({
title: 'Histogram of surface water change intensity.'
});
print(histogram);
// Summarize transition classes in a region of interest.
var area_image_with_transition_class = ee.Image.pixelArea().addBands(transition);
var reduction_results = area_image_with_transition_class.reduceRegion({
reducer: ee.Reducer.sum().group({
groupField: 1,
groupName: 'transition_class_value',
}),
geometry: roi,
scale: 30,
bestEffort: true,
});
print('reduction_results', reduction_results);
var roi_stats = ee.List(reduction_results.get('groups'));
var transition_fc = ee.FeatureCollection(roi_stats.map(createFeature));
print('transition_fc', transition_fc);
// Add a summary chart.
var transition_summary_chart = ui.Chart.feature.byFeature({
features: transition_fc,
xProperty: 'transition_class_name',
yProperties: ['area_m2', 'transition_class_number']
})
.setChartType('PieChart')
.setOptions({
title: 'Summary of transition class areas between 1984 and 2015',
slices: createPieChartSliceDictionary(transition_fc),
sliceVisibilityThreshold: 0 // Don't group small slices.
});
print(transition_summary_chart, '1984 - 2015');
//create filter for 1984 - 2000 and 2000 - 2015
var filtered2000 = transition_fc.filterDate('1984-01-01', '2000-12-31');
print(filtered2000, 'filtered2000');
// Add a summary chart.
var transition_summary_chart1 = ui.Chart.feature.byFeature({
features: filtered2000,
xProperty: 'transition_class_name',
yProperties: ['area_m2', 'transition_class_number']
})
.setChartType('PieChart')
.setOptions({
title: 'Summary of transition class areas between 1984 and 2015',
slices: createPieChartSliceDictionary(transition_fc),
sliceVisibilityThreshold: 0 // Don't group small slices.
});
print(transition_summary_chart1, '1984 - 2000');
////////////////////////////////////////////////////////////
//create maps with center on Aral Lake//
////////////////////////////////////////////////////////////
Map.setCenter(59.414, 45.182, 6);
//add map that shows water occurrence
Map.addLayer({
eeObject: occurrence.updateMask(occurrence.divide(100)),
name: 'Water Occurance (1984 - 2019)',
visParams: VIS_OCCURRENCE
});
//add map that shows the water pixels with a 90% treshhold in occurrence
Map.addLayer({
eeObject: water_mask,
visParams: VIS_WATER_MASK,
name: '90% occurrence water mask'
});
//add map that shows the intensity of water change
Map.addLayer({
eeObject: change,
visParams: VIS_CHANGE,
name: 'occurrence change intensity'
});
//add map that shows water transition
Map.addLayer({
eeObject: transition,
name: 'Transition classes (1984-2015)',
});
Export.image.toDrive({
image: transition,
description: 'transition',
region: roi,
scale: 30,
maxPixels: 1e13,
});
A Map with four different Layers namely the “Water Occurrence (1984 - 2019)”, “90% occurrence water mask”, “occurrence change intensity” and "Transition Classes (1984 - 2015) could be produced. The Water Occurrence (1984 - 2019) layer shows how much of the time a pixel was classified as water (Figure 1). It can therefore be derived if an area is permanently covered with water over the entire time period. The 90 % occurrence water mask shows in which areas the occurrence of water was greater than 90 % but is not further displayed here and can be seen in the original Google Earth Engine layer output.
library(sp)
library(raster)
occurrence <- raster("results/AralLakeTIFF/occurrence.tif")
spplot(occurrence)
Figure 1: Water occurrence in the Aral Lake basin in the periode from 1984 to 2019 in percent
The change intensity of the totality of pixels is shown in a histogram that shows the amount of change in surface water area in percent in relation to the amount of pixels for which these change apply (Figure 2). The histogram shows clearly that the most frequent case is a loss in surface water area of 80 - 90 % followed by a gain in water surface area of 0 - 10 %. Overall the area with loss in surface water highly dominates which is also reflected in the Map that shows where the water change intensity is highest (Figure 3).
Figure 2: Frequency of change in surface water area per pixel in the time period of 1984 - 2019 in the Aral Lake basin
library(sp)
library(raster)
change <- raster("results/AralLakeTIFF/change.tif")
spplot(change)
Figure 3: Water change intensity in percent in the Aral Lake basin in the period from 1984 to 2019
The Transition Classes (1984 - 2015) layer classifies specific regions of the area as certain transition classes in the time period of 1984 until 2015 and displays them in different colours (Figure 4). The occurrence of these transition classes is also displayed as a pie chart where the different assignments of colours to the transition classes can be seen as well as their occurrence in percent (Figure 5). It can be seen that almost 50 % of the surface water area is lost permanently, that there are seasonal changes to consider and only around 18 % of the area is covered permanently with water. The differentiation in two time periods from 1984 to 2000 and from 2000 to 2015 failed and the attempt to filter the feature collection returns an error which could not be solved.
Figure 4: Area of each transition class in the Aral Lake basin from 1984 - 2015
Figure 5: Percentage of each transition class in the time periode from 1984 until 2015 in the Aral Lake basin
For the calculations and visualizations of the water area the JRC Monthly History v1.2 data set was used. This data set contains information about the spatial and temporal distribution and provides statistics on the extent of change of surface water in the time period from 1984 - 2019. These data were generated using scenes from the landsat 5, 7, and 8 satellite which were recorded between 16th March 1984 and 31th December 2019. A classification of each pixel into water or non-water has already been applied using an expert system which produced a monthly history in surface water for the entire time period. In this approach the attempt was to create a function that calculates the pixel area multiplied by the amount of pixels that have been classified as water, map it over the whole image collection and finally get a line chart with the water surface area over time as an output. Find and run the following script in the Google Earth Engine Code Editor here.
Since the code folding for JavaScript did not work the code was implemented as R code which is responsible for the wrong highlighting.
var roi =
/* color: #009999 */
/* displayProperties: [
{
"type": "rectangle"
}
] */
ee.Geometry.Polygon(
[[[57.96380468750002, 46.93522519500926],
[57.96380468750002, 43.659886266041504],
[62.00677343750002, 43.659886266041504],
[62.00677343750002, 46.93522519500926]]], null, false);
var water_history = ee.ImageCollection('JRC/GSW1_2/MonthlyHistory')
.filterBounds(roi);
print(water_history, 'water_history');
// water function:
var waterAreafunction = function(image){
//add band to the image
var water = image.select('water');
//get pixels that are masked as water with '2' in roi
var class2 = ee.Image(1).mask(image.select('water').eq(2).clip(roi));
//calculate pixelArea
var area = ee.Image.pixelArea();
//multiply pixel area by number of pixels that were masked as water
var waterArea = class2.multiply(area);
//add Band with values of water area per image to image
return image.addBands(waterArea);
};
//map function over ImageCollection
var WaterArea = water_history.map(waterAreafunction);
print(WaterArea, 'WaterArea');
//create a time series chart of water surface area
var chart = ui.Chart.image.series({
imageCollection: WaterArea.select('constant'),
region: roi,
scale: 200,
xProperty: 'system:index'
});
print(chart);
//visualisation
var visualization = {
bands: ['water'],
min: 0.0,
max: 2.0,
palette: ['ffffff', 'fffcb8', '0905ff']
};
Map.setCenter(59.414, 45.182, 6);
Map.addLayer(water_history, visualization, 'Water');
A line chart could be produced (Figure 6). A meaningful interpretation is however not possible. There have been numerous issues during the calculation and creation of the function that could not be solved in this effort.
Figure 6: Output of the line chart that should actually map the surface area over time in the Aral Lake basin