-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathera5DailyGEEScript.js
51 lines (38 loc) · 1.59 KB
/
era5DailyGEEScript.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
var bc = ee.FeatureCollection('FAO/GAUL/2015/level1');
// Filter the boundaries to get the British Columbia province
var bcBoundary = bc.filter(ee.Filter.eq('ADM1_CODE', 826));
var bounds = bcBoundary.geometry().bounds();
var mask = function(collection) {
return collection.map(function(image) {
return image.clip(bcBoundary);
});
};
// load era5Daily data
var era5Daily = mask(ee.ImageCollection("ECMWF/ERA5_LAND/DAILY_AGGR").filter(ee.Filter.date('2020-01-01', '2024-05-01')));
// Function to extract a single band from the image collection and create a new image collection
function extract_band(band_name) {
return era5Daily.select(band_name);
}
// Function to convert an image collection to a single image with each image as a band
function collection_to_single_image(image_collection) {
return image_collection.toBands();
}
// Get the list of band names from the first image in the collection
var band_names = era5Daily.first().bandNames().getInfo();
print(band_names) // here you can view the different bands
// Array to hold the images for visualization
var imageLayers = [];
// Extract each band as a separate image and store in the array
band_names.forEach(function(band_name) {
var band_collection = extract_band(band_name);
var single_image = collection_to_single_image(band_collection);
// Adding the image to the array of image layers
imageLayers.push(single_image);
});
var index = 1 // specify the index corresponding to parameter you want to visualize
var vizParams = {
min: 0,
max: 1,
bands: ['20200101_' + band_names[index]]
}
Map.addLayer(imageLayers[index], vizParams);