2

I am writing a script to extract the time series soil moisture values from SMAP soil moisture data using point shapefile and plot it on a line graph in the Google Earth Engine. As SMAP having the daily data coverage but I am getting the pixel values three days interval. Can anyone tell me where is the wrong with my code and addition to that I want to extract the time information also along with date and export it as CSV to Drive.

Below code, I am working

#Point shape file I uploaded, if I can add manually coordinate, please tell me (Not from geomarty addition)
var shp=ee.FeatureCollection('users/SWAT/C01');

// which dataset + where + when
var imageCollection = ee.ImageCollection('NASA_USDA/HSL/SMAP_soil_moisture')
                .filterBounds(shp)
                .filterDate('2018-01-01','2020-08-30');

// select bands -> ssm = surface soil moisture (%)
var soilmoisture = imageCollection.select('smp');

// gget scale
var scale = imageCollection.first().projection().nominalScale();

// Take average
var imageCollection = imageCollection.map(function(image){
  return ee.Image(image.setMulti(image.reduceRegion(ee.Reducer.mean(), shp, scale)));
});

// Get the mean from the dictionary and print it.
var means = imageCollection.aggregate_array('smp');
print('Soil Moisture (%)', means);
// put in a chart
print(ui.Chart.image.seriesByRegion(imageCollection, shp, ee.Reducer.mean(), 'smp', scale));

// Get the mean from the dictionary and print it.
var meanDict = soilmoisture.mean().reduceRegion(ee.Reducer.mean(), shp, scale);
print('Soil Moisture (%)', meanDict);

Map.centerObject(shp, 10);
Map.addLayer(soilmoisture, {min: 0, max: 1}, 'soilmoister imageCollection');  

  

1 Answer 1

0

I would refer to this link and see if it helps get you started:

https://developers.google.com/earth-engine/guides/charts_image_series

Code from link:

// Load Landsat 8 top-of-atmosphere (TOA) input imagery.
var collection = ee.ImageCollection('LANDSAT/LC08/C01/T1_TOA').select('B[1-7]');

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

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

You can export the time series from there.

Also some more in depth coverage here:

https://spatialthoughts.com/2020/04/13/extracting-time-series-ee/

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.