0

Using Google Earth Engine to extract FLDAS dataset for specific coordinates for the time period 1990-2020. I use Rainf_f_tavg Precipitation bands with the default format is kg m-2 s-1. Then i multiply it by * 86400 * 30 to convert that default units to mm/month. But.. there is an error that says

Line 1: ee.ImageCollection(...).filter(...).select(...).multiply is not a function

I have also tried several script combinations : (1)

var dataset=ee.ImageCollection("NASA/FLDAS/NOAH01/C/GL/M/V001")
.filter(ee.Filter.date('2020-12-01', '2021-05-31'));
var layer = dataset.select('Rainf_f_tavg');

var Precip = dataset.expression(
  'P * 86400 * 30', {
    P: dataset.select('Rainf_f_tavg')
    }
  ).float();
  
var band_viz = {
  min: 0,
  max: 400,
  opacity: 1.0,
  palette: ['#FFFFFF', '#00FFFF', '#0080FF', '#DA00FF', '#FFA400','#FF0000']
};

Map.addLayer(Precip, band_viz, 'Precipitation (mm)', true);
Map.addLayer(sampel, {color: 'black'}, 'Sampel');

var testPoint = ee.Feature(sampel.first())
//Map.centerObject(testPoint, 10)
var chart = ui.Chart.image.series({
    imageCollection: dataset.select('Rainf_f_tavg'),
    region: testPoint.geometry()
    }).setOptions({
      interpolateNulls: true,
      lineWidth: 1,
      pointSize: 3,
      title: 'Soil Moisture over Time at a Single Location',
      vAxis: {title: 'Soil'},
      hAxis: {title: 'Date', format: 'YYYY-MMM', gridlines: {count: 12}}
    })
print(chart)

(2)

var dataset=ee.ImageCollection("NASA/FLDAS/NOAH01/C/GL/M/V001")
.filter(ee.Filter.date('2020-12-01', '2021-05-31')).select('Rainf_f_tavg')
.multiply(86400*30);
  
var band_viz = {
  min: 0,
  max: 400,
  opacity: 1.0,
  palette: ['#FFFFFF', '#00FFFF', '#0080FF', '#DA00FF', '#FFA400','#FF0000']
};

Map.addLayer(dataset, band_viz, 'Precipitation (mm)', true);

This error stays the same.

How do I convert it properly? . Errors:

1 Answer 1

3

You are trying to apply the .expression to the entire ImageCollection. Unfortunately .expression can only be applied to an ee.Image() object so you have to map your function over the entire image collection:

print(dataset.first(), 'before')

var rewrite = dataset.map(function(image) {
  return image.addBands(
    image.expression(
  'P * 86400 * 30', {
    P: image.select('Rainf_f_tavg')
    }
  ).float().rename('adjusted'));
});

print(rewrite.first(), 'after')

https://code.earthengine.google.com/99b31f38e1ffe0a280f74c9c3f2c519b

0

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.