content/flux/v0/stdlib/experimental/polyline/rdp.md
polyline.rdp() applies the Ramer Douglas Peucker (RDP) algorithm to input data to downsample curves composed
of line segments into visually indistinguishable curves with fewer points.
(
<-tables: stream[A],
?epsilon: float,
?retention: float,
?timeColumn: string,
?valColumn: string,
) => stream[B] where A: Record, B: Record
{{% caption %}} For more information, see Function type signatures. {{% /caption %}}
Column with Y axis values of the given curve. Default is _value.
Column with X axis values of the given curve. Default is _time.
Maximum tolerance value that determines the amount of compression.
Epsilon should be greater than 0.0.
Percentage of points to retain after downsampling.
Retention rate should be between 0.0 and 100.0.
Input data. Default is piped-forward data (<-).
When using polyline.rdp(), leave both epsilon and retention unspecified
to automatically calculate the maximum tolerance for producing a visually
indistinguishable curve.
import "experimental/polyline"
data
|> polyline.rdp()
{{< expand-wrapper >}} {{% expand "View example input and output" %}}
| _time | _value |
|---|---|
| 2023-04-06T14:59:30Z | 10.56555566168836 |
| 2023-04-06T14:59:40Z | -29.76098586714259 |
| 2023-04-06T14:59:50Z | -67.50435038579738 |
| 2023-04-06T15:00:00Z | -16.758669047964453 |
| 2023-04-06T15:00:10Z | -47.25865245658065 |
| 2023-04-06T15:00:20Z | 66.16082461651365 |
| 2023-04-06T15:00:30Z | -0.9179216017921821 |
| 2023-04-06T15:00:40Z | -56.89169240573004 |
| 2023-04-06T15:00:50Z | 11.358605472976624 |
| 2023-04-06T15:01:00Z | 28.71147881415803 |
| 2023-04-06T15:01:10Z | -30.928830759588756 |
| 2023-04-06T15:01:20Z | -22.411848631056067 |
| 2023-04-06T15:01:30Z | 17.05503606764129 |
| 2023-04-06T15:01:40Z | 9.834382683760559 |
| 2023-04-06T15:01:50Z | -12.62058579127679 |
| 2023-04-06T15:02:00Z | -44.44668391211515 |
| _time | _value |
|---|---|
| 2023-04-06T14:59:30Z | 10.56555566168836 |
| 2023-04-06T14:59:40Z | -29.76098586714259 |
| 2023-04-06T14:59:50Z | -67.50435038579738 |
| 2023-04-06T15:00:00Z | -16.758669047964453 |
| 2023-04-06T15:00:10Z | -47.25865245658065 |
| 2023-04-06T15:00:20Z | 66.16082461651365 |
| 2023-04-06T15:00:30Z | -0.9179216017921821 |
| 2023-04-06T15:00:40Z | -56.89169240573004 |
| 2023-04-06T15:00:50Z | 11.358605472976624 |
| 2023-04-06T15:01:00Z | 28.71147881415803 |
| 2023-04-06T15:01:10Z | -30.928830759588756 |
| 2023-04-06T15:01:20Z | -22.411848631056067 |
| 2023-04-06T15:01:30Z | 17.05503606764129 |
| 2023-04-06T15:01:40Z | 9.834382683760559 |
| 2023-04-06T15:01:50Z | -12.62058579127679 |
| 2023-04-06T15:02:00Z | -44.44668391211515 |
{{% /expand %}} {{< /expand-wrapper >}}
import "experimental/polyline"
data
|> polyline.rdp(epsilon: 1.5)
{{< expand-wrapper >}} {{% expand "View example input and output" %}}
| _time | _value |
|---|---|
| 2023-04-06T14:59:40Z | 10.56555566168836 |
| 2023-04-06T14:59:50Z | -29.76098586714259 |
| 2023-04-06T15:00:00Z | -67.50435038579738 |
| 2023-04-06T15:00:10Z | -16.758669047964453 |
| 2023-04-06T15:00:20Z | -47.25865245658065 |
| 2023-04-06T15:00:30Z | 66.16082461651365 |
| 2023-04-06T15:00:40Z | -0.9179216017921821 |
| 2023-04-06T15:00:50Z | -56.89169240573004 |
| 2023-04-06T15:01:00Z | 11.358605472976624 |
| 2023-04-06T15:01:10Z | 28.71147881415803 |
| 2023-04-06T15:01:20Z | -30.928830759588756 |
| 2023-04-06T15:01:30Z | -22.411848631056067 |
| 2023-04-06T15:01:40Z | 17.05503606764129 |
| 2023-04-06T15:01:50Z | 9.834382683760559 |
| 2023-04-06T15:02:00Z | -12.62058579127679 |
| 2023-04-06T15:02:10Z | -44.44668391211515 |
| _time | _value |
|---|---|
| 2023-04-06T14:59:40Z | 10.56555566168836 |
| 2023-04-06T15:00:00Z | -67.50435038579738 |
| 2023-04-06T15:00:10Z | -16.758669047964453 |
| 2023-04-06T15:00:20Z | -47.25865245658065 |
| 2023-04-06T15:00:30Z | 66.16082461651365 |
| 2023-04-06T15:00:40Z | -0.9179216017921821 |
| 2023-04-06T15:00:50Z | -56.89169240573004 |
| 2023-04-06T15:01:00Z | 11.358605472976624 |
| 2023-04-06T15:01:10Z | 28.71147881415803 |
| 2023-04-06T15:01:20Z | -30.928830759588756 |
| 2023-04-06T15:01:30Z | -22.411848631056067 |
| 2023-04-06T15:01:40Z | 17.05503606764129 |
| 2023-04-06T15:01:50Z | 9.834382683760559 |
| 2023-04-06T15:02:00Z | -12.62058579127679 |
| 2023-04-06T15:02:10Z | -44.44668391211515 |
{{% /expand %}} {{< /expand-wrapper >}}
import "experimental/polyline"
data
|> polyline.rdp(retention: 90.0)
{{< expand-wrapper >}} {{% expand "View example input and output" %}}
| _time | _value |
|---|---|
| 2023-04-06T14:59:40Z | 10.56555566168836 |
| 2023-04-06T14:59:50Z | -29.76098586714259 |
| 2023-04-06T15:00:00Z | -67.50435038579738 |
| 2023-04-06T15:00:10Z | -16.758669047964453 |
| 2023-04-06T15:00:20Z | -47.25865245658065 |
| 2023-04-06T15:00:30Z | 66.16082461651365 |
| 2023-04-06T15:00:40Z | -0.9179216017921821 |
| 2023-04-06T15:00:50Z | -56.89169240573004 |
| 2023-04-06T15:01:00Z | 11.358605472976624 |
| 2023-04-06T15:01:10Z | 28.71147881415803 |
| 2023-04-06T15:01:20Z | -30.928830759588756 |
| 2023-04-06T15:01:30Z | -22.411848631056067 |
| 2023-04-06T15:01:40Z | 17.05503606764129 |
| 2023-04-06T15:01:50Z | 9.834382683760559 |
| 2023-04-06T15:02:00Z | -12.62058579127679 |
| 2023-04-06T15:02:10Z | -44.44668391211515 |
| _time | _value |
|---|---|
| 2023-04-06T14:59:40Z | 10.56555566168836 |
| 2023-04-06T15:00:00Z | -67.50435038579738 |
| 2023-04-06T15:00:10Z | -16.758669047964453 |
| 2023-04-06T15:00:20Z | -47.25865245658065 |
| 2023-04-06T15:00:30Z | 66.16082461651365 |
| 2023-04-06T15:00:40Z | -0.9179216017921821 |
| 2023-04-06T15:00:50Z | -56.89169240573004 |
| 2023-04-06T15:01:00Z | 11.358605472976624 |
| 2023-04-06T15:01:10Z | 28.71147881415803 |
| 2023-04-06T15:01:20Z | -30.928830759588756 |
| 2023-04-06T15:01:30Z | -22.411848631056067 |
| 2023-04-06T15:01:40Z | 17.05503606764129 |
| 2023-04-06T15:01:50Z | 9.834382683760559 |
| 2023-04-06T15:02:10Z | -44.44668391211515 |
{{% /expand %}} {{< /expand-wrapper >}}