How to make Rainfall Map using Google Earth Engine || Rainfall Map || Temporal Data||GEE||1981-2023
GIS Analysis GIS Analysis
2.84K subscribers
5,576 views
100

 Published On Dec 10, 2023

Certainly! Let's break down the code step by step:


Load CHIRPS precipitation dataset:






var chirps = ee.ImageCollection('UCSB-CHG/CHIRPS/DAILY')
.filterDate('2020-01-01', '2020-12-31')
.select('precipitation');
This part loads the CHIRPS (Climate Hazards Group InfraRed Precipitation with Station data) daily precipitation dataset for the specified date range in the year 2020. It selects the 'precipitation' band from the dataset.
Calculate the annual sum of precipitation:






var annualPrecipitation = chirps.sum();
It calculates the sum of daily precipitation values over the entire year, resulting in an annual precipitation image.
Load FAO GAUL dataset (g250m level) and filter Pakistan:






var countries = ee.FeatureCollection("FAO/GAUL/2015/level0");
var pakistan = countries.filter(ee.Filter.eq('ADM0_NAME', 'Pakistan'));
It loads the FAO Global Administrative Unit Layers (GAUL) dataset for country boundaries (at the 'g250m' level) and then filters out the feature corresponding to Pakistan.
Clip the precipitation data to the Pakistan boundary:






var clippedPrecipitation = annualPrecipitation.clip(pakistan);
It clips the annual precipitation data to the boundary of Pakistan.
Define visualization parameters:






var precipitationVis = {
min: 0,
max: 1000,
palette: ['white', 'blue', 'cyan', 'green', 'yellow', 'red']
};
Visualization parameters for mapping annual precipitation are defined, specifying the minimum, maximum values, and a color palette.
Add the clipped precipitation layer to the map:






Map.centerObject(pakistan, 5);
Map.addLayer(clippedPrecipitation, precipitationVis, 'Annual Precipitation (mm)');
It centers the map on Pakistan and adds the clipped precipitation layer with the defined visualization parameters.
Add legend:






var legend = ui.Panel({
style: {
position: 'bottom-right',
padding: '8px 15px'
}
});
It creates a panel to hold the legend, positioned at the bottom-right corner of the map.
Create legend entries function:






var makeLegend = function(colors, labels) {
// ... (See next point for details)
};
It defines a function to create legend entries based on colors and labels.
Define legend colors and labels:






var legendColors = precipitationVis.palette;
var legendLabels = ['0', '100', '200', '300', '400', '500+'];
It specifies the colors and labels for the legend entries.
Add legend entries to the panel and add the legend to the map:






legend.add(makeLegend(legendColors, legendLabels));
Map.add(legend);
It generates legend entries using the defined colors and labels, adds them to the legend panel, and then adds the legend to the map.
Create a chart of monthly precipitation:






var monthlyPrecipitationChart = ui.Chart.image.seriesByRegion({
imageCollection: chirps,
regions: pakistan,
reducer: ee.Reducer.sum(),
scale: 1000,
xProperty: 'system:time_start',
seriesProperty: 'ADM0_NAME'
});
It creates a time series chart of monthly precipitation for Pakistan using the CHIRPS dataset.
Customize the chart appearance:






monthlyPrecipitationChart.setOptions({
title: 'Monthly Precipitation in Pakistan (2020)',
hAxis: {title: 'Date'},
vAxis: {title: 'Precipitation (mm)'},
lineWidth: 2,
pointSize: 4,
colors: ['blue']
});
It sets options for the appearance of the chart, including title, axis labels, line width, point size, and line color.
Display the chart:






print(monthlyPrecipitationChart);
It prints the generated chart to the console in the Code Editor.

show more

Share/Embed