Currently I am writing on my script to extract a time series of SMAP pixel values of the band 'smp', however, my studyarea is rather small and hence the script I found online in this community from AADR

Extracting Soil moisture value using Google Earth Engine?

doesn't fit entirely for my question, since it develops on the mean of several pixels.

The script I am working with:

var table = ee.FeatureCollection("users/marinnvum/DownloadNDVI"),
    geometry = /* color: #d63000 */ee.Geometry.Polygon(
        [[[16.62138331919588, 48.21312568441956],
          [16.619409213360917, 48.20875013496642],
          [16.62061084299959, 48.2084355385735],
          [16.625159869488847, 48.2077777398707],
          [16.62558902293123, 48.209007530577786],
          [16.624473223981035, 48.21020869299206],
          [16.625288615521562, 48.211409827232984]]]);

// Dataset 

var imageCollection = ee.ImageCollection('NASA_USDA/HSL/SMAP_soil_moisture')

// Select band -> smp = surface soil moisture (%)

var soilmoisture = imageCollection.select('smp');

// gget scale

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

// Take pixel // I know that here is the problem, presumably with ee.Reducer.count() --> I only need one pixel from the time series which has 324 elements

var imageCollection = imageCollection.map(function(image){
  return ee.Image(image.setMulti(image.reduceRegion(ee.Reducer.count(), geometry, scale)));

// Get the images from the dictionary and print it. --> I also have the feeling that aggregate_array doesn't give the relevant data output

var means = imageCollection.aggregate_array('smp');
print('Bodenfeuchte in %', means);

// put in a chart 

print(ui.Chart.image.seriesByRegion(imageCollection, geometry, ee.Reducer.count(), 'smp', scale));

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

I replaced ee.Reducer.count() already with ee.Reducer.toList in order to have the relevant values as a list and then, export them. But eventually my values I am looking for are NULL.

Interestingly if I //Create a list of image objects.

var imageList = imageCollection.toList(324);
print('imageList', imageList);

I get provided with all relevant images, however, smp or ssm or whatever band you look for, has no values at all if you check them:


1 Answer 1


You were almost there.

ee.Reducer.count() returns the number of non-null pixels in your region at the scale you request the calculation occur. However, if you want the time series of soil moisture within your study area (geometry) you need to take the mean of all soil moisture values within it (and not count the number of pixels with non-null soil moisture). Even if the SMAP pixel is larger than your study area, you can still use ee.Reducer.mean() and it will return the pixel's value (mean of something is itself).

Here is the corrected script will all the unwanted lines commented out. And the desired time series is shown below.

enter image description here

  • Ahh.. Thanks for the help. @kkrao Much appreciated and solves my problems.
    – daves_ma
    Oct 16, 2020 at 7:55

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.