[GRASS-user] Median filtering time series in time only

Veronica Andreo veroandreo at gmail.com
Wed Jan 27 06:59:09 PST 2021


El mié., 27 ene. 2021 11:33, <nik at nikosalexandris.net> escribió:

> Thank you Vero.
>
> Consider the following time series [1, 2, 2, 6, 3, 3, 4, 4, 3, 2, 2, 1] <-
> evolution of a pixel in time.
>
> Say this is always the same pixel indexed at [0, 0] in each of 12 raster
> maps registered in a GRASS GIS STRDS.
>
> Median filtering pixel-wise in time, only, with a temporal window=3, would
> then be doing:
>
> 1st pixel would be replaced by the median of [0, 1, 2]
>
> 2nd pixel would be replaced by then median of [1, 2, 2]
>
> 3rd pixel would be replaced by the median of [2, 2, 6]
>
> 4th pixel would be replaved by the median of [2, 6, 3]
>
> etc.
>
>
Got it, it's more like a rolling median what you need.

Have you tried r.series.filter? From the manual page, it seems that's
exactly what it does if you set method=median and winsize=3 (given that
winsize is in time)

Otherwise, we can think harder on how to do that with t.rast.algebra and
the neighborhood modifier only moving in time. But, you should explore how
to expose the median function from r.mapcalc first, since it's not
available in t.rast.algebra yet

Doing a spatial median over a 2D (sub)window of each raster map in a GRASS
> GIS STRDS is not wanted here.  I hope this is more clear now.
>

This is not what I suggested in the previous email either. Both r.series
and t.rast.series will estimate the median per pixel in time (either for
the whole series or the time period you want). Would it be possible then
with so e sort of special for cycle?

Best,
Vero

Nikos
>
>
> ---
>
>
>
> On 2021-01-27 16:04, Veronica Andreo wrote:
>
> What exactly do you mean by median-filtering in time only, Nikos? Get the
> median and then filtering out all pixels above/below that value? If that's
> the case, then maybe some of the examples here
> https://grasswiki.osgeo.org/wiki/Temporal_data_processing#Spatio-temporal_algebra_with_STRDS
> might be of help
>
> Basically, you first estimate the median of the series (or the period you
> are interested in) either with r.series or t.rast.series and then use
> t.rast.mapcalc or t.rast.algebra to get only pixels below/above that value
> represented pixelwise in the median map. It can also be a single value of
> course.
>
> Does that make sense?
>
> best,
> Vero
>
>
> El mié., 27 ene. 2021 08:44, <nik at nikosalexandris.net> escribió:
>
> I am trying to median-filter time series in time and not in space.
>
> Not sure `r.series.filter` is the right tool.
> I skimmed through the manual, the paper and the source code. Yet I am
> asking for a confirmation.
> Its (odd integer) parameter `winsize=` implies a moving window (of size
> winsize^2).
> Does this rather filter images, of a time series, in space?
> Or does the `winsize` here refer to the length of a moving temporal
> window?
>
> Then, there is `r.series.lwr`.
> Can I use the tool with `order=0` and `delta=1` (or `order=3` and
> `delta=1`)
> and perform a moving average filtering in time?
> It's not median. Still I'd like to see a filtering in time-only effect.
>
> And, now I recall `r.hants`.
> Is there a way to use it for filtering-out only lows and highs (`-l` and
> `-h` respectively) pixel-wise in time, without interpolating nor
> extrapolating?
>
> Else, I guess there should be a way to build a 'custom' filter using
> `t.rast.algebra` using its temporal neighborhood modifier.
> It's convenient if one the tools above does already median-filtering in
> time-only.
>
> Kind regards, Nikos
> _______________________________________________
> grass-user mailing list
> grass-user at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/grass-user
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20210127/ad0c4f5a/attachment-0001.html>


More information about the grass-user mailing list