2

I got a list of values and I could print them to the Console. It looks like this:

{
 "chlor_a": 0.12718113166405862
 },
 {
 "chlor_a": 0.37072379355468843
 },

How can I export it to my Drive account in csv format?

This is the code so far:

var bo=ee.FeatureCollection('users/broadsky2008/Border');
var chla = ee.ImageCollection("NASA/OCEANDATA/MODIS-Aqua/L3SMI")
.filterDate('2012-7-04', '2018-1-25')
.select('chlor_a');
var reduceR = function(image) {
 return image.set('number',image.reduceRegion({
 reducer: ee.Reducer.mean(),
 geometry: bo.geometry(),
 }));
};
// Map the function over the collection and display the result.
var mChla=chla.map(reduceR);
// Get a list of the numbers.
var numberList = mChla.aggregate_array('number');
print(numberList);
PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Jan 29, 2018 at 16:23

1 Answer 1

3

The argument(s) to set() should be either a key, value pair or a dictionary. Here is your (corrected) example, assuming you've got a geometry called geometry defined somewhere:

var chla = ee.ImageCollection("NASA/OCEANDATA/MODIS-Aqua/L3SMI")
 .filterDate('2018-1-04', '2018-1-25')
 .select('chlor_a');
var reduceR = function(image) {
 return image.set(image.reduceRegion({
 reducer: ee.Reducer.first(),
 geometry: geometry,
 }));
};
var mChla=chla.map(reduceR);
Export.table.toDrive({
 collection: ee.FeatureCollection(mChla), 
 description: 'foo', 
 fileNamePrefix: 'foo', 
 fileFormat: 'CSV', 
 selectors: ['chlor_a']
});
Kersten
10k3 gold badges40 silver badges60 bronze badges
answered Jan 30, 2018 at 4:17
0

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.