0% found this document useful (0 votes)
4 views40 pages

Chan Chan Climate and Landcover Analysis

The document outlines a script for analyzing environmental data in the Chan Chan area, utilizing various datasets including land cover, elevation, fire occurrences, precipitation, and drought indices. It includes methods for visualizing and exporting this data, as well as defining the study area's geographical boundaries. The script was created by Tereza Břežná and Josef Laštovička for a master's thesis in 2025.

Uploaded by

tariqabbasepi
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views40 pages

Chan Chan Climate and Landcover Analysis

The document outlines a script for analyzing environmental data in the Chan Chan area, utilizing various datasets including land cover, elevation, fire occurrences, precipitation, and drought indices. It includes methods for visualizing and exporting this data, as well as defining the study area's geographical boundaries. The script was created by Tereza Břežná and Josef Laštovička for a master's thesis in 2025.

Uploaded by

tariqabbasepi
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Příloha

Skript Chan Chan


// CITATIONS
/*
Abatzoglou, J.T., S.Z. Dobrowski, S.A. Parks, K.C. Hegewisch, 2018, Terraclimate, a high-resolution global
dataset of monthly climate and climatic water balance from 1958-2015, Scientific Data 5:170191,
doi:10.1038/sdata.2017.191
Funk, Chris, Pete Peterson, Martin Landsfeld, Diego Pedreros, James Verdin, Shraddhanand Shukla, Gregory
Husak, James Rowland, Laura Harrison, Andrew Hoell & Joel Michaelsen. "The climate hazards infrared
precipitation with stations-a new environmental record for monitoring extremes". Scientific Data 2, 150066.
doi:10.1038/sdata.2015.66 2015.
Jarvis, A., H.I. Reuter, A. Nelson, E. Guevara. 2008. Hole-filled SRTM for the globe Version 4, available from
the CGIAR-CSI SRTM 90m Database: [Link]
MODIS Collection 6 NRT Hotspot / Active Fire Detections MCD14DL. Available on-line
[Link] doi:10.5067/FIRMS/MODIS/[Link].006
Zanaga, D., Van De Kerchove, R., De Keersmaecker, W., Souverijns, N., Brockmann, C., Quast, R., Wevers, J.,
Grosu, A., Paccini, A., Vergnaud, S., Cartus, O., Santoro, M., Fritz, S., Georgieva, I., Lesiv, M., Carter, S.,
Herold, M., Li, Linlin, Tsendbazar, N.E., Ramoino, F., Arino, O., 2021. ESA WorldCover 10 m 2020 v100.
(doi:10.5281/zenodo.5571936)
Script created by Tereza Břežná and Josef Laštovička (2025).
*/
// DATA
// Landcover
var landcover = [Link]('ESA/WorldCover/v100')
.filter([Link]('2020-01-01', '2021-01-01'))
.select('Map')
.first();
// DEM
var dem = [Link]('CGIAR/SRTM90_V4');
var slope = [Link](dem);
var aspect = [Link](dem);
// Fire
var fire = [Link]('FIRMS')
.select('confidence');
// Precipitation
var precipitation = [Link]('UCSB-CHG/CHIRPS/DAILY')
.select('precipitation');
// Drought
var drought = [Link]('IDAHO_EPSCOR/TERRACLIMATE')
.select('pdsi');

1
// STUDY AREA
// Define the coordinates for the locality and create a geometry object from coordinate
var coordinates_chan_chan = [
[-79.09987688445521, -8.102886535968365],
[-79.10107851409389, -8.104925902067075],
[-79.10245180510951, -8.106455419857474],
[-79.10228014373256, -8.107814986344406],
[-79.10004854583217, -8.109684382759541],
[-79.09586306303066, -8.113253206325629],
[-79.09036989896816, -8.117671705881802],
[-79.08298845975918, -8.123449670425194],
[-79.07766695707363, -8.127953026295835],
[-79.07165880888027, -8.13296613657826],
[-79.06822558134121, -8.135430184759526],
[-79.06565066068691, -8.135175283925935],
[-79.06341906278652, -8.133051104009043],
[-79.0623890945248, -8.12999226515765],
[-79.06135912626308, -8.12761226585235],
[-79.06084414213223, -8.124383447047425],
[-79.05990000455898, -8.121239572199388],
[-79.05929918973965, -8.118010702137086],
[-79.05929918973965, -8.115291633531504],
[-79.06007166593594, -8.11222971075956],
[-79.0605866500668, -8.107726178607617],
[-79.06075831144375, -8.104242279516761],
[-79.06041498868984, -8.101523117802476],
[-79.05904169767422, -8.098464038916656],
[-79.05723925321621, -8.095574887517916],
[-79.05517931669277, -8.093025619074215],
[-79.05414934843105, -8.090646287308234],
[-79.05311938016933, -8.08726723740061],
[-79.05277605741543, -8.084038094763322],
[-79.05311938016933, -8.081233818343192],
[-79.05380602567715, -8.078684459231722],
[-79.05535097806973, -8.07613508401928],
[-79.05749674528164, -8.074180552122254],

2
[-79.06032915800137, -8.07282087218033],
[-79.06324740140957, -8.071801109220456],
[-79.06668062894863, -8.071291226775251],
[-79.0704571792416, -8.07078134368657],
[-79.07414789884609, -8.07078134368657],
[-79.07758112638516, -8.0717161288576],
[-79.08007021635098, -8.074010592379821],
[-79.08135767667812, -8.076220063452393],
[-79.0817868301205, -8.079389594466631],
[-79.0817868301205, -8.082533796226366],
[-79.08247347562832, -8.084913175865749],
[-79.08358927457851, -8.086867655783669],
[-79.08530588834805, -8.088312265286705],
[-79.08835166321137, -8.090308495464978],
[-79.09187072143891, -8.092262949226958],
[-79.09418815002778, -8.094302369132969],
[-79.09590476379731, -8.096596704186695],
[-79.0981363616977, -8.099570822766301]
];
var chan_chan = [Link](coordinates_chan_chan).buffer(10000);
var chan_chan_fc = [Link](chan_chan);
[Link]({collection: chan_chan_fc, description: 'chan_chan', fileFormat: 'SHP'});
// LEGEND
var landcover_vis = {
bands: ['Map'],
};
var dem_vis = {min: -7, max: 594, palette: ['006400', '66a000', 'b5a100', 'd98a00', '8b2500']};
var slope_vis = {min: 0, max: 32.69379806518555, palette: ['006400', '32cd32', 'ffff00', 'ff4500', 'd60000']};
var aspect_vis = {min: 0, max: 356.5998840332031, palette: ['00008b', '1e90ff', '87cefa', '32cd32', 'ffd700',
'ffa500', 'ff6347', 'b22222']};
var fire_vis = {min: 48, max: 93, palette: ['fee5d9', 'fcae91', 'fb6a4a', 'de2d26', 'a50f15']};
var precipitation_vis= {min: 0.2196880280971527, max: 0.3718412518501282, palette: ['eff3ff', 'bdd7e7',
'6baed6', '3182bd', '08519c']};
var drought_vis = {min: 107.89583333333333, max: 237, palette: ['ca0020', 'f4a582', 'f7f7f7', '92c5de',
'0571b0']};
// MAPS, TIME SERIES AND EXPORTS
// Zoom to study area

3
[Link](chan_chan, 12);
// DEM
[Link]([Link](chan_chan), dem_vis, 'SRTM DEM Chan Chan', false);
[Link]([Link](chan_chan), slope_vis, 'SRTM slope Chan Chan', false);
[Link]([Link](chan_chan), aspect_vis, 'SRTM aspect Chan Chan', false);
[Link]({image: [Link](chan_chan), description: 'srtm_dem_chan_chan', scale: 30, crs:
'EPSG:4326', region: chan_chan, maxPixels: 3784216672400});
[Link]({image: [Link](chan_chan), description: 'srtm_slope_chan_chan', scale: 30, crs:
'EPSG:4326', region: chan_chan, maxPixels: 3784216672400});
[Link]({image: [Link](chan_chan), description: 'srtm_aspect_chan_chan', scale: 30, crs:
'EPSG:4326', region: chan_chan, maxPixels: 3784216672400});
// Landcover
[Link]([Link](chan_chan), landcover_vis, 'ESA WorldCover Landcover Chan Chan', false);
[Link]({image: [Link](chan_chan), description: 'esa_worldcover_landcover_chan_chan',
scale: 8, crs: 'EPSG:4326', region: chan_chan, maxPixels: 3784216672400});
// Fire
[Link]([Link]([Link]('2020-01-01', '2025-01-01')).max().clip(chan_chan), fire_vis, 'FIRMS fire
Chan Chan', false);
[Link]({image: [Link]([Link]('2020-01-01', '2025-01-01')).max().clip(chan_chan),
description: 'firms_fire_chan_chan', scale: 1000, crs: 'EPSG:4326', region: chan_chan, maxPixels:
3784216672400});
var fire_chart_chan_chan = [Link]({
imageCollection: [Link]([Link]('2020-01-01', '2025-01-01')),
regions: chan_chan,
reducer: [Link](),
scale: 1000,
seriesProperty: 'id'
}).setChartType('ScatterChart').setOptions({
title: 'FIRMS fire Chan Chan',
hAxis: {title: 'Date', titleTextStyle: {italic: false, bold: true}},
vAxis: {title: 'Detection confidence [%]', titleTextStyle: {italic: false, bold: true}},
pointSize: 5,
colors: ['red'],
});
print(fire_chart_chan_chan);
// Precipitation
[Link]([Link]([Link]('2009-01-01', '2017-01-01')).mean().clip(chan_chan),
precipitation_vis, 'CHIRPS precipitation Chan Chan', false);

4
[Link]({image: [Link]([Link]('2009-01-01', '2017-01-
01')).mean().clip(chan_chan), description: 'chirps_precipitation_chan_chan', scale: 5566, crs: 'EPSG:4326',
region: chan_chan, maxPixels: 3784216672400});
var precipitation_chart_chan_chan = [Link]({
imageCollection: [Link]([Link]('2009-01-01', '2017-01-01')),
regions: chan_chan,
reducer: [Link](),
scale: 5566,
seriesProperty: 'id'
}).setOptions({
title: 'Precipitation Chan Chan',
hAxis: {title: 'Date', titleTextStyle: {italic: false, bold: true}},
vAxis: {title: 'mm', titleTextStyle: {italic: false, bold: true}},
lineWidth: 1,
colors: ['blue'],
});
print(precipitation_chart_chan_chan);
// Drought
[Link]([Link]([Link]('2009-01-01', '2017-01-01')).mean().clip(chan_chan), drought_vis,
'TerraClimate PDSI Chan Chan', false);
[Link]({image: [Link]([Link]('2009-01-01', '2017-01-01')).mean().clip(chan_chan),
description: 'terraclimate_drought_chan_chan', scale: 4638.3, crs: 'EPSG:4326', region: chan_chan, maxPixels:
3784216672400});
var drought_chart_chan_chan = [Link]({
imageCollection: [Link]([Link]('2009-01-01', '2017-01-01')),
regions: chan_chan,
reducer: [Link](),
scale: 4638.3,
seriesProperty: 'id'
}).setOptions({
title: 'Drought Chan Chan',
hAxis: {title: 'Date', titleTextStyle: {italic: false, bold: true}},
vAxis: {title: 'PDSI index', titleTextStyle: {italic: false, bold: true}},
lineWidth: 1,
colors: ['red'],
});
print(drought_chart_chan_chan);
// Study area

5
[Link]([Link]([Link](chan_chan.coordinates().get(0))), {color: 'red',
width: 2, fillColor: '00000000'}, 'Chan Chan study area', false);
// APP
// App header title
var header = [Link]('Chan Chan', {fontSize: '25px', fontWeight: 'bold', color: 'orange'});
// Introduction
var introduction = [Link](
'App created for master thesis by Tereza Břežná (2025).',
{fontSize: '15px'});
// Separator 1
var separator_1 = [Link]([
[Link]({
value: '____________________________________________',
style: {fontWeight: 'bold', color: 'orange'},
})]);
// Legend label 1
var legend_label_1 = [Link]({
value: 'ESA Landcover',
style: {fontWeight: 'bold', fontSize: '16px', margin: '10px 5px'}
});
// Legend 1
function legend_1() {
var legend = [Link]({
style: {
padding: '8px',
backgroundColor: 'white'
}
});
// Function to create one row of the legend
var make_row = function(color, name) {
var color_box = [Link]({
style: {
backgroundColor: color,
padding: '8px',
margin: '0 0 4px 0'
}

6
});
var description = [Link]({
value: name,
style: {margin: '0 0 4px 6px'}
});
return [Link]({
widgets: [color_box, description],
layout: [Link]('horizontal')
});
};
// Define the legend entries
var legendEntries = [
{color: '#006400', name: 'Tree cover'},
{color: '#ffbb22', name: 'Shrubland'},
{color: '#ffff4c', name: 'Grassland'},
{color: '#f096ff', name: 'Cropland'},
{color: '#fa0000', name: 'Built-up'},
{color: '#b4b4b4', name: 'Bare / sparse vegetation'},
{color: '#0064c8', name: 'Permanent water bodies'},
{color: '#0096a0', name: 'Herbaceous wetland'},
];
// Add each entry to the legend
[Link](function(entry) {
[Link](make_row([Link], [Link]));
});
return legend;
}
// Legend label 2
var legend_label_2 = [Link]({
value: 'SRTM DEM',
style: {fontWeight: 'bold', fontSize: '16px', margin: '10px 5px'}
});
// Legend 2
function legend_2(parameters) {
var lon = [Link]().select('longitude');
var gradient = [Link](([Link] - [Link]) / 100.0).add([Link]);

7
var legendImage = [Link](parameters);
var thumb = [Link]({
image: legendImage,
params: {bbox: '0,0,100,8', dimensions: '256x20'},
style: {position: 'bottom-center'}
});
var panel = [Link]({
widgets: [
[Link]('low altitude'),
[Link]({style: {stretch: 'horizontal'}}),
[Link]('high altitude')
],
layout: [Link]('horizontal'),
style: {stretch: 'horizontal', maxWidth: '270px', padding: '0px 0px 0px 8px'}
});
return [Link]().add(panel).add(thumb);
}
// Legend label 3
var legend_label_3 = [Link]({
value: 'SRTM slope',
style: {fontWeight: 'bold', fontSize: '16px', margin: '10px 5px'}
});
// Legend 3
function legend_3(parameters) {
var lon = [Link]().select('longitude');
var gradient = [Link](([Link] - [Link]) / 100.0).add([Link]);
var legendImage = [Link](parameters);
var thumb = [Link]({
image: legendImage,
params: {bbox: '0,0,100,8', dimensions: '256x20'},
style: {position: 'bottom-center'}
});
var panel = [Link]({
widgets: [
[Link]('low slope'),
[Link]({style: {stretch: 'horizontal'}}),

8
[Link]('high slope')
],
layout: [Link]('horizontal'),
style: {stretch: 'horizontal', maxWidth: '270px', padding: '0px 0px 0px 8px'}
});
return [Link]().add(panel).add(thumb);
}
// Legend label 4
var legend_label_4 = [Link]({
value: 'SRTM aspect',
style: {fontWeight: 'bold', fontSize: '16px', margin: '10px 5px'}
});
// Legend 4
function legend_4 (parameters) {
var lon = [Link]().select('longitude');
var gradient = [Link](([Link] - [Link]) / 100.0).add([Link]);
var legendImage = [Link](parameters);
var thumb = [Link]({
image: legendImage,
params: {bbox: '0,0,100,8', dimensions: '256x20'},
style: {position: 'bottom-center'}
});
var panel = [Link]({
widgets: [
[Link]('0°'),
[Link]({style: {stretch: 'horizontal'}}),
[Link]('360°')
],
layout: [Link]('horizontal'),
style: {stretch: 'horizontal', maxWidth: '270px', padding: '0px 0px 0px 8px'}
});
return [Link]().add(panel).add(thumb);
}
// Legend label 5
var legend_label_5 = [Link]({
value: 'FIRMS Fire',

9
style: {fontWeight: 'bold', fontSize: '16px', margin: '10px 5px'}
});
// Legend 5
function legend_5(parameters) {
var lon = [Link]().select('longitude');
var gradient = [Link](([Link] - [Link]) / 100.0).add([Link]);
var legendImage = [Link](parameters);
var thumb = [Link]({
image: legendImage,
params: {bbox: '0,0,100,8', dimensions: '256x20'},
style: {position: 'bottom-center'}
});
var panel = [Link]({
widgets: [
[Link]('low risk'),
[Link]({style: {stretch: 'horizontal'}}),
[Link]('high risk')
],
layout: [Link]('horizontal'),
style: {stretch: 'horizontal', maxWidth: '270px', padding: '0px 0px 0px 8px'}
});
return [Link]().add(panel).add(thumb);
}
// Legend label 6
var legend_label_6 = [Link]({
value: 'CHIRPS precipitation',
style: {fontWeight: 'bold', fontSize: '16px', margin: '10px 5px'}
});
// Legend 6
function legend_6(parameters) {
var lon = [Link]().select('longitude');
var gradient = [Link](([Link] - [Link]) / 100.0).add([Link]);
var legendImage = [Link](parameters);
var thumb = [Link]({
image: legendImage,
params: {bbox: '0,0,100,8', dimensions: '256x20'},

10
style: {position: 'bottom-center'}
});
var panel = [Link]({
widgets: [
[Link]('low precipitation'),
[Link]({style: {stretch: 'horizontal'}}),
[Link]('high precipitation')
],
layout: [Link]('horizontal'),
style: {stretch: 'horizontal', maxWidth: '270px', padding: '0px 0px 0px 8px'}
});
return [Link]().add(panel).add(thumb);
}
// Legend label 7
var legend_label_7 = [Link]({
value: 'TerraClimate PDSI',
style: {fontWeight: 'bold', fontSize: '16px', margin: '10px 5px'}
});
// Legend 7
function legend_7(parameters) {
var lon = [Link]().select('longitude');
var gradient = [Link](([Link] - [Link]) / 100.0).add([Link]);
var legendImage = [Link](parameters);
var thumb = [Link]({
image: legendImage,
params: {bbox: '0,0,100,8', dimensions: '256x20'},
style: {position: 'bottom-center'}
});
var panel = [Link]({
widgets: [
[Link]('low PDSI'),
[Link]({style: {stretch: 'horizontal'}}),
[Link]('high PDSI')
],
layout: [Link]('horizontal'),
style: {stretch: 'horizontal', maxWidth: '270px', padding: '0px 0px 0px 8px'}

11
});
return [Link]().add(panel).add(thumb);
}
// Legend label 8
var legend_label_8 = [Link]({
value: 'Study area',
style: {fontWeight: 'bold', fontSize: '16px', margin: '10px 5px'}
});
// Legend 8
var legend_8 = [Link]([
[Link]({
value: '___________',
style: {fontWeight: 'bold', color: 'red'},
})]);
// Separator 2
var separator_2 = [Link]([
[Link]({
value: '____________________________________________',
style: {fontWeight: 'bold', color: 'orange'},
})]);
// Author
var author = [Link](
'Created by Tereza Břežná and Josef Laštovička (2025). The GUI inspired by Abigail Barenblitt & Temilola
Fatoyinbo (2020).',
{fontSize: '15px', fontWeight: 'bold'});
// References
var references_title = [Link](
'References: ',
{fontSize: '15px', fontWeight: 'bold'});
var references_1 = [Link](
'Abatzoglou, J.T., S.Z. Dobrowski, S.A. Parks, K.C. Hegewisch, 2018, Terraclimate, a high-resolution global
dataset of monthly climate and climatic water balance from 1958-2015, Scientific Data 5:170191,
doi:10.1038/sdata.2017.191',
{fontSize: '15px'});
var references_2 = [Link](
'Funk, Chris, Pete Peterson, Martin Landsfeld, Diego Pedreros, James Verdin, Shraddhanand Shukla, Gregory
Husak, James Rowland, Laura Harrison, Andrew Hoell & Joel Michaelsen. "The climate hazards infrared

12
precipitation with stations-a new environmental record for monitoring extremes". Scientific Data 2, 150066.
doi:10.1038/sdata.2015.66 2015.',
{fontSize: '15px'});
var references_3 = [Link](
'Jarvis, A., H.I. Reuter, A. Nelson, E. Guevara. 2008. Hole-filled SRTM for the globe Version 4, available from
the CGIAR-CSI SRTM 90m Database: [Link]
{fontSize: '15px'});
var references_4 = [Link](
'MODIS Collection 6 NRT Hotspot / Active Fire Detections MCD14DL. Available on-line
[Link] doi:10.5067/FIRMS/MODIS/[Link].006',
{fontSize: '15px'});
var references_5 = [Link](
'Zanaga, D., Van De Kerchove, R., De Keersmaecker, W., Souverijns, N., Brockmann, C., Quast, R., Wevers, J.,
Grosu, A., Paccini, A., Vergnaud, S., Cartus, O., Santoro, M., Fritz, S., Georgieva, I., Lesiv, M., Carter, S.,
Herold, M., Li, Linlin, Tsendbazar, N.E., Ramoino, F., Arino, O., 2021. ESA WorldCover 10 m 2020 v100.
(doi:10.5281/zenodo.5571936)',
{fontSize: '15px'});
// Create panel with widgets
var panel = [Link]({
widgets: [header, introduction, separator_1, legend_label_1, legend_1(landcover_vis), legend_label_2,
legend_2(dem_vis), legend_label_3, legend_3(slope_vis), legend_label_4, legend_4(aspect_vis),
legend_label_5, legend_5(fire_vis), legend_label_6, legend_6(precipitation_vis), legend_label_7,
legend_7(drought_vis), legend_label_8, legend_8, separator_2, author, references_title, references_1,
references_2, references_3, references_4, references_5],
style: {width: '300px', position: 'middle-right'}
});
// Add panel with widgets to the root of GUI
[Link](0, panel);

Skript Machu Picchu


// CITATIONS
/*
Abatzoglou, J.T., S.Z. Dobrowski, S.A. Parks, K.C. Hegewisch, 2018, Terraclimate, a high-resolution global
dataset of monthly climate and climatic water balance from 1958-2015, Scientific Data 5:170191,
doi:10.1038/sdata.2017.191
Funk, Chris, Pete Peterson, Martin Landsfeld, Diego Pedreros, James Verdin, Shraddhanand Shukla, Gregory
Husak, James Rowland, Laura Harrison, Andrew Hoell & Joel Michaelsen. "The climate hazards infrared
precipitation with stations-a new environmental record for monitoring extremes". Scientific Data 2, 150066.
doi:10.1038/sdata.2015.66 2015.
Jarvis, A., H.I. Reuter, A. Nelson, E. Guevara. 2008. Hole-filled SRTM for the globe Version 4, available from
the CGIAR-CSI SRTM 90m Database: [Link]
MODIS Collection 6 NRT Hotspot / Active Fire Detections MCD14DL. Available on-line
[Link] doi:10.5067/FIRMS/MODIS/[Link].006

13
Tellman, B., J.A. Sullivan, C. Kuhn, A.J. Kettner, C.S. Doyle, G.R. Brakenridge, T. Erickson, D.A. Slayback.
(Accepted.) Satellites observe increasing proportion of population exposed to floods. Nature.
doi:10.1038/s41586-021-03695-w
Zanaga, D., Van De Kerchove, R., De Keersmaecker, W., Souverijns, N., Brockmann, C., Quast, R., Wevers, J.,
Grosu, A., Paccini, A., Vergnaud, S., Cartus, O., Santoro, M., Fritz, S., Georgieva, I., Lesiv, M., Carter, S.,
Herold, M., Li, Linlin, Tsendbazar, N.E., Ramoino, F., Arino, O., 2021. ESA WorldCover 10 m 2020 v100.
(doi:10.5281/zenodo.5571936)
Script created by Tereza Břežná and Josef Laštovička (2025).
*/
// DATA
// Landcover
var landcover = [Link]('ESA/WorldCover/v100')
.filter([Link]('2020-01-01', '2021-01-01'))
.select('Map')
.first();
// DEM
var dem = [Link]('CGIAR/SRTM90_V4');
var slope = [Link](dem);
var aspect = [Link](dem);
// Fire
var fire = [Link]('FIRMS')
.select('confidence');
// Precipitation
var precipitation = [Link]('UCSB-CHG/CHIRPS/DAILY')
.select('precipitation');
// Drought
var drought = [Link]('IDAHO_EPSCOR/TERRACLIMATE')
.select('pdsi');
// Flood
var flood = [Link]('GLOBAL_FLOOD_DB/MODIS_EVENTS/V1')
.select('flooded');
// STUDY AREA
// Define the coordinates for the locality and create a geometry object from coordinate
var coordinates_machu_picchu = [
[-72.54606476177722, -13.161443606488525],
[-72.54622569431811, -13.161527182592085],
[-72.54640808453112, -13.161621205674518],
[-72.54657974590808, -13.161736122726273],

14
[-72.54672994961291, -13.16189282770999],
[-72.5468372379735, -13.162059979582136],
[-72.5468372379735, -13.162279366241304],
[-72.54675140728503, -13.162509199673512],
[-72.5466548477605, -13.162718138970245],
[-72.54657974590808, -13.162965179362892],
[-72.54657974590808, -13.163215906030947],
[-72.54661193241625, -13.16350842015271],
[-72.54671922077685, -13.163706911679276],
[-72.54684796680957, -13.163842721578481],
[-72.54696598400622, -13.16400987212029],
[-72.54697671284228, -13.164218810137168],
[-72.54692306866198, -13.16447835921353],
[-72.54684796680957, -13.164635062443208],
[-72.54680505146533, -13.164896234269918],
[-72.54679432262927, -13.165115618389144],
[-72.54684796680957, -13.16528276806241],
[-72.54690161098986, -13.165397683396613],
[-72.54703035702258, -13.16548125815125],
[-72.54714837421923, -13.165554386038167],
[-72.54732003559619, -13.165648407574993],
[-72.54748096813708, -13.165810101760542],
[-72.54756679882556, -13.165987697781045],
[-72.54757752766162, -13.166238421355487],
[-72.54751315464526, -13.16642646386788],
[-72.54736295094042, -13.166541378665512],
[-72.54713764538317, -13.166562272259286],
[-72.54693379749804, -13.166562272259286],
[-72.54670849194079, -13.166562272259286],
[-72.54651537289172, -13.166624953029908],
[-72.5463329826787, -13.166708527365806],
[-72.54612913479357, -13.166865229168726],
[-72.54596820225268, -13.166959250202348],
[-72.54575595846428, -13.167076889808223],
[-72.54550919523491, -13.167170910760612],
[-72.54531607618584, -13.167264931676883],

15
[-72.54506931295647, -13.167338059031264],
[-72.54485473623528, -13.1674111863638],
[-72.54462943067803, -13.167400739603343],
[-72.5444255827929, -13.167348505794392],
[-72.544264650252, -13.1671604639899],
[-72.54425392141594, -13.16697242204104],
[-72.54434973904367, -13.166680634449298],
[-72.54441411206002, -13.166482145332397],
[-72.54447848507638, -13.166262762437094],
[-72.54451067158456, -13.1660329325265],
[-72.54447848507638, -13.165771761911788],
[-72.54438192555185, -13.165594165734701],
[-72.54413516232248, -13.165521037859651],
[-72.5438883990931, -13.165510591018574],
[-72.54364163586374, -13.165447909962769],
[-72.5434377879786, -13.165427016273936],
[-72.54321248242135, -13.165343441500788],
[-72.54301936337228, -13.16524985498615],
[-72.54292280384774, -13.165030470987134],
[-72.5429335326838, -13.164821533662549],
[-72.54297644802804, -13.164643936796526],
[-72.54301936337228, -13.164466339801743],
[-72.54311592289682, -13.164299189571386],
[-72.54322321125741, -13.164152933026276],
[-72.54333049961801, -13.164006676393841],
[-72.54345924565072, -13.163860419674082],
[-72.54358799168344, -13.163724609784698],
[-72.54369528004403, -13.163536565198175],
[-72.5437060088801, -13.16332762659942],
[-72.54368127180133, -13.16314640180042],
[-72.54370272947345, -13.16292701591765],
[-72.54374564481769, -13.16272852375921],
[-72.54378856016193, -13.162550925375873],
[-72.5438743908504, -13.16239422081306],
[-72.54404605222736, -13.1622061752054],
[-72.54419625593219, -13.162091258374108],

16
[-72.54434645963703, -13.161986788480712],
[-72.54452884985004, -13.161871871546525],
[-72.54471124006305, -13.161777848560284],
[-72.54488290144, -13.16172561355234],
[-72.5450974781612, -13.161652484522508],
[-72.54530132604633, -13.161579355470844],
[-72.54546225858722, -13.16150622639735],
[-72.54564464880023, -13.161422650286637],
[-72.54584849668537, -13.161391309237775]
];
var machu_picchu = [Link](coordinates_machu_picchu).buffer(10000);
var machu_picchu_fc = [Link](machu_picchu);
[Link]({collection: machu_picchu_fc, description:'machu_picchu', fileFormat: 'SHP'});
// LEGEND
var landcover_vis = {
bands: ['Map'],
};
var dem_vis = {min: 1389, max: 4449, palette: ['006400', '66a000', 'b5a100', 'd98a00', '8b2500']};
var slope_vis = {min: 0.4431474804878235, max: 58.10041046142578, palette: ['006400', '32cd32', 'ffff00',
'ff4500', 'd60000']};
var aspect_vis = {min: 0, max: 359.7970886230469, palette: ['00008b', '1e90ff', '87cefa', '32cd32', 'ffd700',
'ffa500', 'ff6347', 'b22222']};
var fire_vis = {min: 34, max: 100, palette: ['fee5d9', 'fcae91', 'fb6a4a', 'de2d26', 'a50f15']};
var precipitation_vis = {min: 2.8269424438476562, max: 4.233745098114014, palette: ['eff3ff', 'bdd7e7',
'6baed6', '3182bd', '08519c']};
var drought_vis = {min: -42.572916666666664, max: 74.13541666666667, palette: ['ca0020', 'f4a582', 'f7f7f7',
'92c5de', '0571b0']};
var flood_vis = {names: ['Flood'], palette: ['0571b0']};
// MAPS, TIME SERIES AND EXPORTS
// Zoom to study area
[Link](machu_picchu, 12);
// DEM
[Link]([Link](machu_picchu), dem_vis, 'SRTM DEM Machu Picchu', false);
[Link]([Link](machu_picchu), slope_vis, 'SRTM slope Machu Picchu', false);
[Link]([Link](machu_picchu), aspect_vis, 'SRTM aspect Machu Picchu', false);
[Link]({image: [Link](machu_picchu), description: 'srtm_dem_machu_picchu', scale: 30, crs:
'EPSG:4326', region: machu_picchu, maxPixels: 3784216672400});

17
[Link]({image: [Link](machu_picchu), description: 'srtm_slope_machu_picchu', scale: 30,
crs: 'EPSG:4326', region: machu_picchu, maxPixels: 3784216672400});
[Link]({image: [Link](machu_picchu), description: 'srtm_aspect_machu_picchu', scale: 30,
crs: 'EPSG:4326', region: machu_picchu, maxPixels: 3784216672400});
// Landcover
[Link]([Link](machu_picchu), landcover_vis, 'ESA WorldCover Landcover Machu Picchu',
false);
[Link]({image: [Link](machu_picchu), description:
'esa_worldcover_landcover_machu_picchu', scale: 8, crs: 'EPSG:4326', region: machu_picchu, maxPixels:
3784216672400});
// Fire
[Link]([Link]([Link]('2020-01-01', '2025-01-01')).max().clip(machu_picchu), {min: 34, max:
100, palette: ['fee5d9', 'fcae91', 'fb6a4a', 'de2d26', 'a50f15']}, 'FIRMS fire Machu Picchu', false);
[Link]({image: [Link]([Link]('2020-01-01', '2025-01-01')).max().clip(machu_picchu),
description: 'firms_fire_macu_picchu', scale: 1000, crs: 'EPSG:4326', region: machu_picchu, maxPixels:
3784216672400});
var fire_chart_machu_picchu = [Link]({
imageCollection: [Link]([Link]('2020-01-01', '2025-01-01')),
regions: machu_picchu,
reducer: [Link](),
scale: 1000,
seriesProperty: 'id'
}).setChartType('ScatterChart').setOptions({
title: 'FIRMS fire Machu Picchu',
hAxis: {title: 'Date', titleTextStyle: {italic: false, bold: true}},
vAxis: {title: 'Detection confidence [%]', titleTextStyle: {italic: false, bold: true}},
pointSize: 5,
colors: ['red'],
});
print(fire_chart_machu_picchu);
// Precipitation
[Link]([Link]([Link]('2009-01-01', '2017-01-01')).mean().clip(machu_picchu),
precipitation_vis, 'CHIRPS precipitation Machu Picchu', false);
[Link]({image: [Link]([Link]('2009-01-01', '2017-01-
01')).mean().clip(machu_picchu), description: 'chirps_precipitation_machu_picchu', scale: 5566, crs:
'EPSG:4326', region: machu_picchu, maxPixels: 3784216672400});
var precipitation_chart_machu_picchu = [Link]({
imageCollection: [Link]([Link]('2009-01-01', '2017-01-01')),
regions: machu_picchu,
reducer: [Link](),

18
scale: 5566,
seriesProperty: 'id'
}).setOptions({
title: 'Precipitation Machu Picchu',
hAxis: {title: 'Date', titleTextStyle: {italic: false, bold: true}},
vAxis: {title: 'mm', titleTextStyle: {italic: false, bold: true}},
lineWidth: 1,
colors: ['blue'],
});
print(precipitation_chart_machu_picchu);
// Drought
[Link]([Link]([Link]('2009-01-01', '2017-01-01')).mean().clip(machu_picchu),
drought_vis, 'TerraClimate PDSI Machu Picchu', false);
[Link]({image: [Link]([Link]('2009-01-01', '2017-01-
01')).mean().clip(machu_picchu), description: 'terraclimate_drought_machu_picchu', scale: 4638.3, crs:
'EPSG:4326', region: machu_picchu, maxPixels: 3784216672400});
var drought_chart_machu_picchu = [Link]({
imageCollection: [Link]([Link]('2009-01-01', '2017-01-01')),
regions: machu_picchu,
reducer: [Link](),
scale: 4638.3,
seriesProperty: 'id'
}).setOptions({
title: 'Drought Machu Picchu',
hAxis: {title: 'Date', titleTextStyle: {italic: false, bold: true}},
vAxis: {title: 'PDSI index', titleTextStyle: {italic: false, bold: true}},
lineWidth: 1,
colors: ['red'],
});
print(drought_chart_machu_picchu);
// Flood
[Link]([Link]([Link]('2000-02-17', '2018-12-10')).max().clip(machu_picchu)
.remap({
from: [1],
to: [1],
defaultValue: NaN
}), flood_vis, 'Global flood DB Machu Picchu', false);

19
[Link]({image: [Link]([Link]('2000-02-17', '2018-12-10')).max().clip(machu_picchu),
description: 'global_flood_db_machu_picchu', scale: 1000, crs: 'EPSG:4326', region: machu_picchu, maxPixels:
3784216672400});
var flood_chart_machu_picchu = [Link]({
imageCollection: [Link]([Link]('2000-02-17', '2018-12-10')),
regions: machu_picchu,
reducer: [Link](),
scale: 30,
seriesProperty: 'id'
}).setChartType('ScatterChart').setOptions({
title: 'Flood Machu Picchu',
hAxis: {title: 'Date', titleTextStyle: {italic: false, bold: true}},
vAxis: {title: '0 – no flood / 1 – flood', titleTextStyle: {italic: false, bold: true}},
pointSize: 5,
colors: ['blue']
});
print(flood_chart_machu_picchu);
// Study area
[Link]([Link]([Link](machu_picchu.coordinates().get(0))), {color: 'red',
width: 2, fillColor: '00000000'}, 'Machu Picchu study area', false);
// APP
// App header title
var header = [Link]('Machu Picchu', {fontSize: '25px', fontWeight: 'bold', color: 'orange'});
// Introduction
var introduction = [Link](
'App created for master thesis by Tereza Břežná (2025).',
{fontSize: '15px'});
// Separator 1
var separator_1 = [Link]([
[Link]({
value: '____________________________________________',
style: {fontWeight: 'bold', color: 'orange'},
})]);
// Legend label 1
var legend_label_1 = [Link]({
value: 'ESA Landcover',
style: {fontWeight: 'bold', fontSize: '16px', margin: '10px 5px'}

20
});
// Legend 1
function legend_1() {
var legend = [Link]({
style: {
padding: '8px',
backgroundColor: 'white'
}
});
// Function to create one row of the legend
var make_row = function(color, name) {
var color_box = [Link]({
style: {
backgroundColor: color,
padding: '8px',
margin: '0 0 4px 0'
}
});
var description = [Link]({
value: name,
style: {margin: '0 0 4px 6px'}
});
return [Link]({
widgets: [color_box, description],
layout: [Link]('horizontal')
});
};
// Define the legend entries
var legendEntries = [
{color: '#006400', name: 'Tree cover'},
{color: '#ffbb22', name: 'Shrubland'},
{color: '#ffff4c', name: 'Grassland'},
{color: '#f096ff', name: 'Cropland'},
{color: '#fa0000', name: 'Built-up'},
{color: '#b4b4b4', name: 'Bare / sparse vegetation'},
{color: '#0064c8', name: 'Permanent water bodies'}

21
];
// Add each entry to the legend
[Link](function(entry) {
[Link](make_row([Link], [Link]));
});
return legend;
}
// Legend label 2
var legend_label_2 = [Link]({
value: 'SRTM DEM',
style: {fontWeight: 'bold', fontSize: '16px', margin: '10px 5px'}
});
// Legend 2
function legend_2(parameters) {
var lon = [Link]().select('longitude');
var gradient = [Link](([Link] - [Link]) / 100.0).add([Link]);
var legendImage = [Link](parameters);
var thumb = [Link]({
image: legendImage,
params: {bbox: '0,0,100,8', dimensions: '256x20'},
style: {position: 'bottom-center'}
});
var panel = [Link]({
widgets: [
[Link]('low altitude'),
[Link]({style: {stretch: 'horizontal'}}),
[Link]('high altitude')
],
layout: [Link]('horizontal'),
style: {stretch: 'horizontal', maxWidth: '270px', padding: '0px 0px 0px 8px'}
});
return [Link]().add(panel).add(thumb);
}
// Legend label 3
var legend_label_3 = [Link]({
value: 'SRTM slope',

22
style: {fontWeight: 'bold', fontSize: '16px', margin: '10px 5px'}
});
// Legend 3
function legend_3(parameters) {
var lon = [Link]().select('longitude');
var gradient = [Link](([Link] - [Link]) / 100.0).add([Link]);
var legendImage = [Link](parameters);
var thumb = [Link]({
image: legendImage,
params: {bbox: '0,0,100,8', dimensions: '256x20'},
style: {position: 'bottom-center'}
});
var panel = [Link]({
widgets: [
[Link]('low slope'),
[Link]({style: {stretch: 'horizontal'}}),
[Link]('high slope')
],
layout: [Link]('horizontal'),
style: {stretch: 'horizontal', maxWidth: '270px', padding: '0px 0px 0px 8px'}
});
return [Link]().add(panel).add(thumb);
}
// Legend label 4
var legend_label_4 = [Link]({
value: 'SRTM aspect',
style: {fontWeight: 'bold', fontSize: '16px', margin: '10px 5px'}
});
// Legend 4
function legend_4 (parameters) {
var lon = [Link]().select('longitude');
var gradient = [Link](([Link] - [Link]) / 100.0).add([Link]);
var legendImage = [Link](parameters);
var thumb = [Link]({
image: legendImage,
params: {bbox: '0,0,100,8', dimensions: '256x20'},

23
style: {position: 'bottom-center'}
});
var panel = [Link]({
widgets: [
[Link]('0°'),
[Link]({style: {stretch: 'horizontal'}}),
[Link]('360°')
],
layout: [Link]('horizontal'),
style: {stretch: 'horizontal', maxWidth: '270px', padding: '0px 0px 0px 8px'}
});
return [Link]().add(panel).add(thumb);
}
// Legend label 5
var legend_label_5 = [Link]({
value: 'FIRMS Fire',
style: {fontWeight: 'bold', fontSize: '16px', margin: '10px 5px'}
});
// Legend 5
function legend_5(parameters) {
var lon = [Link]().select('longitude');
var gradient = [Link](([Link] - [Link]) / 100.0).add([Link]);
var legendImage = [Link](parameters);
var thumb = [Link]({
image: legendImage,
params: {bbox: '0,0,100,8', dimensions: '256x20'},
style: {position: 'bottom-center'}
});
var panel = [Link]({
widgets: [
[Link]('low risk'),
[Link]({style: {stretch: 'horizontal'}}),
[Link]('high risk')
],
layout: [Link]('horizontal'),
style: {stretch: 'horizontal', maxWidth: '270px', padding: '0px 0px 0px 8px'}

24
});
return [Link]().add(panel).add(thumb);
}
// Legend label 6
var legend_label_6 = [Link]({
value: 'CHIRPS precipitation',
style: {fontWeight: 'bold', fontSize: '16px', margin: '10px 5px'}
});
// Legend 6
function legend_6(parameters) {
var lon = [Link]().select('longitude');
var gradient = [Link](([Link] - [Link]) / 100.0).add([Link]);
var legendImage = [Link](parameters);
var thumb = [Link]({
image: legendImage,
params: {bbox: '0,0,100,8', dimensions: '256x20'},
style: {position: 'bottom-center'}
});
var panel = [Link]({
widgets: [
[Link]('low precipitation'),
[Link]({style: {stretch: 'horizontal'}}),
[Link]('high precipitation')
],
layout: [Link]('horizontal'),
style: {stretch: 'horizontal', maxWidth: '270px', padding: '0px 0px 0px 8px'}
});
return [Link]().add(panel).add(thumb);
}
// Legend label 7
var legend_label_7 = [Link]({
value: 'TerraClimate PDSI',
style: {fontWeight: 'bold', fontSize: '16px', margin: '10px 5px'}
});
// Legend 7
function legend_7(parameters) {

25
var lon = [Link]().select('longitude');
var gradient = [Link](([Link] - [Link]) / 100.0).add([Link]);
var legendImage = [Link](parameters);
var thumb = [Link]({
image: legendImage,
params: {bbox: '0,0,100,8', dimensions: '256x20'},
style: {position: 'bottom-center'}
});
var panel = [Link]({
widgets: [
[Link]('low PDSI'),
[Link]({style: {stretch: 'horizontal'}}),
[Link]('high PDSI')
],
layout: [Link]('horizontal'),
style: {stretch: 'horizontal', maxWidth: '270px', padding: '0px 0px 0px 8px'}
});
return [Link]().add(panel).add(thumb);
}
// Legend label 8
var legend_label_8 = [Link]({
value: 'Global Flood Database',
style: {fontWeight: 'bold', fontSize: '16px', margin: '10px 5px'}
});
// Legend 8
function legend_8(landcover_vis) {
var legend = [Link]({
style: {
padding: '8px',
backgroundColor: 'white'
}
});
// Function to create one row of the legend
var make_row = function(color, name) {
var color_box = [Link]({
style: {

26
backgroundColor: color,
padding: '8px',
margin: '0 0 4px 0'
}
});
var description = [Link]({
value: name,
style: {margin: '0 0 4px 6px'}
});
return [Link]({
widgets: [color_box, description],
layout: [Link]('horizontal')
});
};
// Add each row to the legend panel
for (var i = 0; i < flood_vis.[Link]; i++) {
[Link](make_row(flood_vis.palette[i], landcover_vis.names[i]));
}
return legend;
}
// Legend label 9
var legend_label_9 = [Link]({
value: 'Study area',
style: {fontWeight: 'bold', fontSize: '16px', margin: '10px 5px'}
});
// Legend 9
var legend_9 = [Link]([
[Link]({
value: '___________',
style: {fontWeight: 'bold', color: 'red'},
})]);
// Separator 2
var separator_2 = [Link]([
[Link]({
value: '____________________________________________',
style: {fontWeight: 'bold', color: 'orange'},

27
})]);
// Author
var author = [Link](
'Created by Tereza Břežná and Josef Laštovička (2025). The GUI inspired by Abigail Barenblitt & Temilola
Fatoyinbo (2020).',
{fontSize: '15px', fontWeight: 'bold'});
// References
var references_title = [Link](
'References: ',
{fontSize: '15px', fontWeight: 'bold'});
var references_1 = [Link](
'Abatzoglou, J.T., S.Z. Dobrowski, S.A. Parks, K.C. Hegewisch, 2018, Terraclimate, a high-resolution global
dataset of monthly climate and climatic water balance from 1958-2015, Scientific Data 5:170191,
doi:10.1038/sdata.2017.191',
{fontSize: '15px'});
var references_2 = [Link](
'Funk, Chris, Pete Peterson, Martin Landsfeld, Diego Pedreros, James Verdin, Shraddhanand Shukla, Gregory
Husak, James Rowland, Laura Harrison, Andrew Hoell & Joel Michaelsen. "The climate hazards infrared
precipitation with stations-a new environmental record for monitoring extremes". Scientific Data 2, 150066.
doi:10.1038/sdata.2015.66 2015.',
{fontSize: '15px'});
var references_3 = [Link](
'Jarvis, A., H.I. Reuter, A. Nelson, E. Guevara. 2008. Hole-filled SRTM for the globe Version 4, available from
the CGIAR-CSI SRTM 90m Database: [Link]
{fontSize: '15px'});
var references_4 = [Link](
'MODIS Collection 6 NRT Hotspot / Active Fire Detections MCD14DL. Available on-line
[Link] doi:10.5067/FIRMS/MODIS/[Link].006',
{fontSize: '15px'});
var references_5 = [Link](
'Tellman, B., J.A. Sullivan, C. Kuhn, A.J. Kettner, C.S. Doyle, G.R. Brakenridge, T. Erickson, D.A. Slayback.
(Accepted.) Satellites observe increasing proportion of population exposed to floods. Nature.
doi:10.1038/s41586-021-03695-w',
{fontSize: '15px'});
var references_6 = [Link](
'Zanaga, D., Van De Kerchove, R., De Keersmaecker, W., Souverijns, N., Brockmann, C., Quast, R., Wevers, J.,
Grosu, A., Paccini, A., Vergnaud, S., Cartus, O., Santoro, M., Fritz, S., Georgieva, I., Lesiv, M., Carter, S.,
Herold, M., Li, Linlin, Tsendbazar, N.E., Ramoino, F., Arino, O., 2021. ESA WorldCover 10 m 2020 v100.
(doi:10.5281/zenodo.5571936)',
{fontSize: '15px'});
// Create panel with widgets

28
var panel = [Link]({
widgets: [header, introduction, separator_1, legend_label_1, legend_1(landcover_vis), legend_label_2,
legend_2(dem_vis), legend_label_3, legend_3(slope_vis), legend_label_4, legend_4(aspect_vis),
legend_label_5, legend_5(fire_vis), legend_label_6, legend_6(precipitation_vis), legend_label_7,
legend_7(drought_vis), legend_label_8, legend_8(flood_vis), legend_label_9, legend_9, separator_2, author,
references_title, references_1, references_2, references_3, references_4, references_5, references_6],
style: {width: '300px', position: 'middle-right'}
});
// Add panel with widgets to the root of GUI
[Link](0, panel);

Skript Petra
// CITATIONS
/*
Abatzoglou, J.T., S.Z. Dobrowski, S.A. Parks, K.C. Hegewisch, 2018, Terraclimate, a high-resolution global
dataset of monthly climate and climatic water balance from 1958-2015, Scientific Data 5:170191,
doi:10.1038/sdata.2017.191
Funk, Chris, Pete Peterson, Martin Landsfeld, Diego Pedreros, James Verdin, Shraddhanand Shukla, Gregory
Husak, James Rowland, Laura Harrison, Andrew Hoell & Joel Michaelsen. "The climate hazards infrared
precipitation with stations-a new environmental record for monitoring extremes". Scientific Data 2, 150066.
doi:10.1038/sdata.2015.66 2015.
Jarvis, A., H.I. Reuter, A. Nelson, E. Guevara. 2008. Hole-filled SRTM for the globe Version 4, available from
the CGIAR-CSI SRTM 90m Database: [Link]
Zanaga, D., Van De Kerchove, R., De Keersmaecker, W., Souverijns, N., Brockmann, C., Quast, R., Wevers, J.,
Grosu, A., Paccini, A., Vergnaud, S., Cartus, O., Santoro, M., Fritz, S., Georgieva, I., Lesiv, M., Carter, S.,
Herold, M., Li, Linlin, Tsendbazar, N.E., Ramoino, F., Arino, O., 2021. ESA WorldCover 10 m 2020 v100.
(doi:10.5281/zenodo.5571936)
Script created by Tereza Břežná and Josef Laštovička (2025).
*/
// DATA
// Landcover
var landcover = [Link]('ESA/WorldCover/v100')
.filter([Link]('2020-01-01', '2021-01-01'))
.select('Map')
.first();
// DEM
var dem = [Link]('CGIAR/SRTM90_V4');
var slope = [Link](dem);
var aspect = [Link](dem);
// Precipitation
var precipitation = [Link]('UCSB-CHG/CHIRPS/DAILY')

29
.select('precipitation');
// Drought
var drought = [Link]('IDAHO_EPSCOR/TERRACLIMATE')
.select('pdsi');
// STUDY AREA
// Define the coordinates for the locality and create a geometry object from coordinate
var coordinates_petra = [
[35.35217784411402, 30.45217750835594],
[35.34805797106714, 30.446850042573708],
[35.34187816149683, 30.44033830007297],
[35.33707164294214, 30.431457950306537],
[35.332265124387455, 30.42239416565066],
[35.326771960324955, 30.412920021217797],
[35.32265208727808, 30.401668280209535],
[35.315785632199955, 30.39219212419436],
[35.30960582262964, 30.383307393007062],
[35.30342601305933, 30.374421853972922],
[35.29724620348902, 30.364350599981027],
[35.28900645739527, 30.35664835292549],
[35.28145335680933, 30.34926884701286],
[35.27321361071558, 30.340972815573224],
[35.26428721911402, 30.32852745005912],
[35.26016734606714, 30.31963693486383],
[35.26016734606714, 30.305410432382864],
[35.26497386462183, 30.2941463201036],
[35.27390025622339, 30.284659748292206],
[35.28351329333277, 30.276951233199725],
[35.296559557981205, 30.269835143362748],
[35.30891917712183, 30.265683852720734],
[35.32059215075464, 30.259753133038675],
[35.33295176989527, 30.25500829940641],
[35.345998034543705, 30.250263236564845],
[35.35904429919214, 30.24551794453544],
[35.37209056384058, 30.242552020642172],
[35.38376353747339, 30.24195882512182],
[35.39680980212183, 30.241365626020976],

30
[35.41054271227808, 30.242552020642172],
[35.42152904040308, 30.244924766918075],
[35.43251536852808, 30.2484837789106],
[35.44350169665308, 30.25382205518354],
[35.45174144274683, 30.26093930563026],
[35.45929454333277, 30.270428170553593],
[35.46272777087183, 30.279916118360777],
[35.46753428942652, 30.292367657774886],
[35.47096751696558, 30.303631974370283],
[35.47646068102808, 30.314894996842842],
[35.47989390856714, 30.324378643383703],
[35.47989390856714, 30.337417158273595],
[35.47852061755152, 30.34926884701286],
[35.47646068102808, 30.3640814396253],
[35.47440074450464, 30.377114665590998],
[35.47302745348902, 30.388961545045966],
[35.47165416247339, 30.401991453471734],
[35.47028087145777, 30.413835316248726],
[35.46547435290308, 30.425085654845034],
[35.45998118884058, 30.4369267151109],
[35.45242808825464, 30.44580656685489],
[35.44350169665308, 30.45113408967123],
[35.43526195055933, 30.45586942103686],
[35.425648913449955, 30.460604522289962],
[35.411916003293705, 30.464155697205708],
[35.39955638415308, 30.464747547105585],
[35.38651011950464, 30.464747547105585],
[35.37689708239527, 30.463563843709714],
[35.36728404528589, 30.460012647218335],
[35.35904429919214, 30.455277517199985]
];
var petra = [Link](coordinates_petra).buffer(10000);
var petra_fc = [Link](petra);
[Link]({collection: petra_fc, description:'petra', fileFormat: 'SHP'});
// LEGEND
var landcover_vis = {

31
bands: ['Map'],
};
var dem_vis = {min: 38, max: 1702, palette: ['006400', '66a000', 'b5a100', 'd98a00', '8b2500']};
var slope_vis = {min: 0.0772908627986908, max: 23.814130783081055, palette: ['006400', '32cd32', 'ffff00',
'ff4500', 'd60000']};
var aspect_vis = {min: 0, max: 359.126220703125, palette: ['00008b', '1e90ff', '87cefa', '32cd32', 'ffd700',
'ffa500', 'ff6347', 'b22222']};
var precipitation_vis= {min: 0.26999372243881226, max: 0.7291492819786072, palette: ['eff3ff', 'bdd7e7',
'6baed6', '3182bd', '08519c']};
var drought_vis = {min: -218.56666666666666, max: -134.35, palette: ['ca0020', 'f4a582', 'f7f7f7', '92c5de',
'0571b0']};
// MAPS, TIME SERIES AND EXPORTS
// Zoom to study area
[Link](petra, 9);
// DEM
[Link]([Link](petra), dem_vis, 'SRTM DEM Petra', false);
[Link]([Link](petra), slope_vis, 'SRTM slope Petra', false);
[Link]([Link](petra), aspect_vis, 'SRTM aspect Petra', false);
[Link]({image: [Link](petra), description: 'srtm_dem_petra', scale: 30, crs: 'EPSG:4326',
region: petra, maxPixels: 3784216672400});
[Link]({image: [Link](petra), description: 'srtm_slope_petra', scale: 30, crs: 'EPSG:4326',
region: petra, maxPixels: 3784216672400});
[Link]({image: [Link](petra), description: 'srtm_aspect_petra', scale: 30, crs: 'EPSG:4326',
region: petra, maxPixels: 3784216672400});
// Landcover
[Link]([Link](petra), landcover_vis, 'ESA WorldCover Landcover Petra', false);
[Link]({image: [Link](petra), description: 'esa_worldcover_landcover_petra', scale: 7,
crs: 'EPSG:4326', region: petra, maxPixels: 3784216672400});
// Precipitation
[Link]([Link]([Link]('2018-01-01', '2023-01-01')).mean().clip(petra),
precipitation_vis, 'CHIRPS precipitation Petra', false);
[Link]({image: [Link]([Link]('2018-01-01', '2023-01-01')).mean().clip(petra),
description: 'chirps_precipitation_petra', scale: 5566, crs: 'EPSG:4326', region: petra, maxPixels:
3784216672400});
var precipitation_chart_petra = [Link]({
imageCollection: [Link]([Link]('2018-01-01', '2023-01-01')),
regions: petra,
reducer: [Link](),
scale: 5566,
seriesProperty: 'id'

32
}).setOptions({
title: 'Precipitation Petra',
hAxis: {title: 'Date', titleTextStyle: {italic: false, bold: true}},
vAxis: {title: 'mm', titleTextStyle: {italic: false, bold: true}},
lineWidth: 1,
colors: ['blue'],
});
print(precipitation_chart_petra);
// Drought
[Link]([Link]([Link]('2018-01-01', '2023-01-01')).mean().clip(petra), drought_vis,
'TerraClimate PDSI Petra', false);
[Link]({image: [Link]([Link]('2018-01-01', '2023-01-01')).mean().clip(petra),
description: 'terraclimate_drought_petra', scale: 4638.3, crs: 'EPSG:4326', region: petra, maxPixels:
3784216672400});
var drought_chart_petra = [Link]({
imageCollection: [Link]([Link]('2018-01-01', '2023-01-01')),
regions: petra,
reducer: [Link](),
scale: 4638.3,
seriesProperty: 'id'
}).setOptions({
title: 'Drought Petra',
hAxis: {title: 'Date', titleTextStyle: {italic: false, bold: true}},
vAxis: {title: 'PDSI index', titleTextStyle: {italic: false, bold: true}},
lineWidth: 1,
colors: ['red'],
});
print(drought_chart_petra);
// Study area
[Link]([Link]([Link]([Link]().get(0))), {color: 'red', width: 2,
fillColor: '00000000'}, 'Petra study area', false);
// APP
// App header title
var header = [Link]('Petra', {fontSize: '25px', fontWeight: 'bold', color: 'orange'});
// Introduction
var introduction = [Link](
'App created for master thesis by Tereza Břežná (2025).',

33
{fontSize: '15px'});
// Separator 1
var separator_1 = [Link]([
[Link]({
value: '____________________________________________',
style: {fontWeight: 'bold', color: 'orange'},
})]);
// Legend label 1
var legend_label_1 = [Link]({
value: 'ESA Landcover',
style: {fontWeight: 'bold', fontSize: '16px', margin: '10px 5px'}
});
// Legend 1
function legend_1() {
var legend = [Link]({
style: {
padding: '8px',
backgroundColor: 'white'
}
});
// Function to create one row of the legend
var make_row = function(color, name) {
var color_box = [Link]({
style: {
backgroundColor: color,
padding: '8px',
margin: '0 0 4px 0'
}
});
var description = [Link]({
value: name,
style: {margin: '0 0 4px 6px'}
});
return [Link]({
widgets: [color_box, description],
layout: [Link]('horizontal')

34
});
};
// Define the legend entries
var legendEntries = [
{color: '#006400', name: 'Tree cover'},
{color: '#ffbb22', name: 'Shrubland'},
{color: '#ffff4c', name: 'Grassland'},
{color: '#f096ff', name: 'Cropland'},
{color: '#fa0000', name: 'Built-up'},
{color: '#b4b4b4', name: 'Bare / sparse vegetation'},
{color: '#0064c8', name: 'Permanent water bodies'}
];
// Add each entry to the legend
[Link](function(entry) {
[Link](make_row([Link], [Link]));
});
return legend;
}
// Legend label 2
var legend_label_2 = [Link]({
value: 'SRTM DEM',
style: {fontWeight: 'bold', fontSize: '16px', margin: '10px 5px'}
});
// Legend 2
function legend_2(parameters) {
var lon = [Link]().select('longitude');
var gradient = [Link](([Link] - [Link]) / 100.0).add([Link]);
var legendImage = [Link](parameters);
var thumb = [Link]({
image: legendImage,
params: {bbox: '0,0,100,8', dimensions: '256x20'},
style: {position: 'bottom-center'}
});
var panel = [Link]({
widgets: [
[Link]('low altitude'),

35
[Link]({style: {stretch: 'horizontal'}}),
[Link]('high altitude')
],
layout: [Link]('horizontal'),
style: {stretch: 'horizontal', maxWidth: '270px', padding: '0px 0px 0px 8px'}
});
return [Link]().add(panel).add(thumb);
}
// Legend label 3
var legend_label_3 = [Link]({
value: 'SRTM slope',
style: {fontWeight: 'bold', fontSize: '16px', margin: '10px 5px'}
});
// Legend 3
function legend_3(parameters) {
var lon = [Link]().select('longitude');
var gradient = [Link](([Link] - [Link]) / 100.0).add([Link]);
var legendImage = [Link](parameters);
var thumb = [Link]({
image: legendImage,
params: {bbox: '0,0,100,8', dimensions: '256x20'},
style: {position: 'bottom-center'}
});
var panel = [Link]({
widgets: [
[Link]('low slope'),
[Link]({style: {stretch: 'horizontal'}}),
[Link]('high slope')
],
layout: [Link]('horizontal'),
style: {stretch: 'horizontal', maxWidth: '270px', padding: '0px 0px 0px 8px'}
});
return [Link]().add(panel).add(thumb);
}
// Legend label 4
var legend_label_4 = [Link]({

36
value: 'SRTM aspect',
style: {fontWeight: 'bold', fontSize: '16px', margin: '10px 5px'}
});
// Legend 4
function legend_4 (parameters) {
var lon = [Link]().select('longitude');
var gradient = [Link](([Link] - [Link]) / 100.0).add([Link]);
var legendImage = [Link](parameters);
var thumb = [Link]({
image: legendImage,
params: {bbox: '0,0,100,8', dimensions: '256x20'},
style: {position: 'bottom-center'}
});
var panel = [Link]({
widgets: [
[Link]('0°'),
[Link]({style: {stretch: 'horizontal'}}),
[Link]('360°')
],
layout: [Link]('horizontal'),
style: {stretch: 'horizontal', maxWidth: '270px', padding: '0px 0px 0px 8px'}
});
return [Link]().add(panel).add(thumb);
}
// Legend label 5
var legend_label_5 = [Link]({
value: 'CHIRPS precipitation',
style: {fontWeight: 'bold', fontSize: '16px', margin: '10px 5px'}
});
// Legend 5
function legend_5(parameters) {
var lon = [Link]().select('longitude');
var gradient = [Link](([Link] - [Link]) / 100.0).add([Link]);
var legendImage = [Link](parameters);
var thumb = [Link]({
image: legendImage,

37
params: {bbox: '0,0,100,8', dimensions: '256x20'},
style: {position: 'bottom-center'}
});
var panel = [Link]({
widgets: [
[Link]('low precipitation'),
[Link]({style: {stretch: 'horizontal'}}),
[Link]('high precipitation')
],
layout: [Link]('horizontal'),
style: {stretch: 'horizontal', maxWidth: '270px', padding: '0px 0px 0px 8px'}
});
return [Link]().add(panel).add(thumb);
}
// Legend label 6
var legend_label_6 = [Link]({
value: 'TerraClimate PDSI',
style: {fontWeight: 'bold', fontSize: '16px', margin: '10px 5px'}
});
// Legend 6
function legend_6(parameters) {
var lon = [Link]().select('longitude');
var gradient = [Link](([Link] - [Link]) / 100.0).add([Link]);
var legendImage = [Link](parameters);
var thumb = [Link]({
image: legendImage,
params: {bbox: '0,0,100,8', dimensions: '256x20'},
style: {position: 'bottom-center'}
});
var panel = [Link]({
widgets: [
[Link]('low PDSI'),
[Link]({style: {stretch: 'horizontal'}}),
[Link]('high PDSI')
],
layout: [Link]('horizontal'),

38
style: {stretch: 'horizontal', maxWidth: '270px', padding: '0px 0px 0px 8px'}
});
return [Link]().add(panel).add(thumb);
}
// Legend label 7
var legend_label_7 = [Link]({
value: 'Study area',
style: {fontWeight: 'bold', fontSize: '16px', margin: '10px 5px'}
});
// Legend 7
var legend_7 = [Link]([
[Link]({
value: '___________',
style: {fontWeight: 'bold', color: 'red'},
})]);
// Separator 2
var separator_2 = [Link]([
[Link]({
value: '____________________________________________',
style: {fontWeight: 'bold', color: 'orange'},
})]);
// Author
var author = [Link](
'Created by Tereza Břežná and Josef Laštovička (2025). The GUI inspired by Abigail Barenblitt & Temilola
Fatoyinbo (2020).',
{fontSize: '15px', fontWeight: 'bold'});
// References
var references_title = [Link](
'References: ',
{fontSize: '15px', fontWeight: 'bold'});
var references_1 = [Link](
'Abatzoglou, J.T., S.Z. Dobrowski, S.A. Parks, K.C. Hegewisch, 2018, Terraclimate, a high-resolution global
dataset of monthly climate and climatic water balance from 1958-2015, Scientific Data 5:170191,
doi:10.1038/sdata.2017.191',
{fontSize: '15px'});
var references_2 = [Link](

39
'Funk, Chris, Pete Peterson, Martin Landsfeld, Diego Pedreros, James Verdin, Shraddhanand Shukla, Gregory
Husak, James Rowland, Laura Harrison, Andrew Hoell & Joel Michaelsen. "The climate hazards infrared
precipitation with stations-a new environmental record for monitoring extremes". Scientific Data 2, 150066.
doi:10.1038/sdata.2015.66 2015.',
{fontSize: '15px'});
var references_3 = [Link](
'Jarvis, A., H.I. Reuter, A. Nelson, E. Guevara. 2008. Hole-filled SRTM for the globe Version 4, available from
the CGIAR-CSI SRTM 90m Database: [Link]
{fontSize: '15px'});
var references_4 = [Link](
'Zanaga, D., Van De Kerchove, R., De Keersmaecker, W., Souverijns, N., Brockmann, C., Quast, R., Wevers, J.,
Grosu, A., Paccini, A., Vergnaud, S., Cartus, O., Santoro, M., Fritz, S., Georgieva, I., Lesiv, M., Carter, S.,
Herold, M., Li, Linlin, Tsendbazar, N.E., Ramoino, F., Arino, O., 2021. ESA WorldCover 10 m 2020 v100.
(doi:10.5281/zenodo.5571936)',
{fontSize: '15px'});
// Create panel with widgets
var panel = [Link]({
widgets: [header, introduction, separator_1, legend_label_1, legend_1(landcover_vis), legend_label_2,
legend_2(dem_vis), legend_label_3, legend_3(slope_vis), legend_label_4, legend_4(aspect_vis),
legend_label_5, legend_5(precipitation_vis), legend_label_6, legend_6(drought_vis), legend_label_7, legend_7,
separator_2, author, references_title, references_1, references_2, references_3, references_4],
style: {width: '300px', position: 'middle-right'}
});
// Add panel with widgets to the root of GUI
[Link](0, panel);

40

You might also like