I am creating a time-series chart of cloud cover. I calculate the cloud score for image using a custom function and store it as a cloud
property.
Finally, I try to create a chart as follows:
- Get the list comprised of each image's cloud score using
aggregate_array
var cs_list = image_col.aggregate_array('cloud);
- Finally, creating a series chart
var chrt = ui.Chart.array.values(cs_list, 1);
print(chrt);
And following is the script code:
var img_col = ee.ImageCollection("COPERNICUS/S2")
.filterDate('2018-05-01', '2018-07-30')
.filterBounds(region_of_interest_geometry);
var col_with_cloudiness = img_col.map(function(image) {
var cloud_score = compute_cloud_score(image); // function to get cloud_score e.g 0.3454
return image.set('cloud', cloud_score); // set new property
});
var cs_list = col_with_cloudiness.aggregate_array('cloud');
print(cs_list); // JSON [0.2564 (type Obj), 0.0573 (type Obj), ...]. Want Array [0.2564 (type Number), 0.0573 (type Number)]
print(ui.Chart.array.values(cs_list, 1));
On running the code, I ran into the following issue: the cloud-score list contains numbers which are of type object. And so instead of getting line plot, several lines' legends representing each list element(score) gets created
How to convert them to numbers or create an array of cloud scores as actual numbers?