1

I'm new to Google Earth Engine.

I'm trying to create a time-series of SMOS for a point. I have selected the coordinates of the point and am now trying to export the table as a .csv.

My script so far is:

var collection = ee.ImageCollection("NASA_USDA/HSL/soil_moisture").select('ssm');

// Define a region of interest as a buffer around a point.
var geom = ee.Geometry.Point(40.44, 3.12).buffer(500);

// Create and print the chart.
print(ui.Chart.image.series(collection, geom, ee.Reducer.mean(), 30));

// Export the time-series as a csv.
Export.table.toDrive({collection: ssm, description: 'mandera', 
  selectors: 'date, value', fileFormat: 'CSV'});

I know I'm very close to what I need but I can't seem to be able to figure out how to export the timeseries as a .csv file in my Drive. Also, how can I name the file so I find it once it's exported?

I have seen the answer to this: Create time series and export it to csv GEE But I think I might be missing a step...

0

1 Answer 1

0

To export a CSV, you first want to create an ee.FeatureCollection. You can map over your collection, and call reduceRegion() with an ee.Reducer.mean() reducer to get the mean value for each image. Use that value to construct a feature to return. The resulting feature collection is what you should export.

var collection = ee.ImageCollection("NASA_USDA/HSL/soil_moisture").select('ssm');

// Define a region of interest as a buffer around a point.
var geom = ee.Geometry.Point(40.44, 3.12).buffer(500);

var timeSeries = collection.map(function (image) {
  var date = image.date().format('yyyy-MM-dd')
  var value = image
    .clip(geom)
    .reduceRegion({
      reducer: ee.Reducer.mean(),
      scale: 30
    }).get('ssm')
  return ee.Feature(null, {value: value, date: date})
})

// Create and print the chart.
print(ui.Chart.feature.byFeature(timeSeries, 'date', ['value']))

// Export the time-series as a csv.
Export.table.toDrive({
  collection: timeSeries, 
  description: 'mandera', 
  selectors: 'date, value', 
  fileFormat: 'CSV'
});

https://code.earthengine.google.com/70f66dad02aef26b924511fe6f24ea84

how can I name the file so I find it once it's exported?

The description property in toDrive() is the name your CSS file.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.