I am trying to plot the time series chart of the detected water area by otsu's method in Sentinel-1 images as a smoothed average curve.

I found two approaches to this for the Google Earth Engine:

  1. Using the Savitzky-Golay filter or
  2. Smoothing via moving time window

Actually the first variant with Savitzky-Golay filter is very brilliant. Unfortunately the time scale from a certain point in time is considered here and I would use the original 'system:time_start' for the chart.

So I used the second variant with moving time window. The problem here is that the calculated average is far to high and the bad performance. When viewing a longer period of several months I get the following error 'Error generating chart: Computation timed out'.

Here is the code in Google Earth Engine: https://code.earthengine.google.com/94d17969df4c88abc7b59dfd9ecda3a9

Can someone tell me where the problem is or does anyone know a better solution?

I would be very happy about a clue.

1 Answer 1


Maybe try to unwire some of the processing pipelines in your script. Earth Engine really adheres that map/reduce principle, with a minimum amount of processing defined in every branch of its processing graph.

It is quite heavy to add new images as bands in every step (water, median, etc.), this forces Earth Engine to do more computations than needed, and the processing gets close to O(n^2) as well with that join when 60 days window is used. That is probably why it times out. You can find out more if you debug your script with Run > Profiler, though it might be difficult to interpret its results.

There is no need to add water image every time as a new image if you are only interested in the area value, adding a new property would be enough.

I took a challenge to rewrite your script instead of fixing, reproducing the same functionality: https://code.earthengine.google.com/80619a72b5201de0b0f1edf6e35d8650.

There are some hard-coded pieces, like setting min/max for y axes, otherwise, you only see noise points and no trend.

Also, for performance reasons, some parameters are changed:

  • Scale (changed from 10m to 30m)
  • Time search interval (decreased from 30d to 20d)
  • Speckle focal smoothing filter is removed (also the source of slowness) - temporal smoothing already does a good job to reduce it

You can still click on blue or red points, notice, that in this case images are replaced with ui.Map.Layer.setEeObject().

enter image description here

With a large number of images, it will still take quite some time, but it seems to run even for nearly 1000x images:

enter image description here

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.