{"id":20850642,"url":"https://github.com/atsyplenkov/filtrs","last_synced_at":"2026-04-16T09:32:16.462Z","repository":{"id":229110347,"uuid":"775791920","full_name":"atsyplenkov/filtrs","owner":"atsyplenkov","description":"Rust-boosted linear and spatial filtering in R","archived":false,"fork":false,"pushed_at":"2026-01-26T10:58:26.000Z","size":21224,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-02-06T13:07:30.542Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/atsyplenkov.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-03-22T03:38:32.000Z","updated_at":"2026-01-26T10:58:30.000Z","dependencies_parsed_at":"2024-11-18T08:39:40.988Z","dependency_job_id":null,"html_url":"https://github.com/atsyplenkov/filtrs","commit_stats":null,"previous_names":["atsyplenkov/filtrs"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/atsyplenkov/filtrs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atsyplenkov%2Ffiltrs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atsyplenkov%2Ffiltrs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atsyplenkov%2Ffiltrs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atsyplenkov%2Ffiltrs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/atsyplenkov","download_url":"https://codeload.github.com/atsyplenkov/filtrs/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atsyplenkov%2Ffiltrs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31879987,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-16T09:23:21.276Z","status":"ssl_error","status_checked_at":"2026-04-16T09:23:15.028Z","response_time":69,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-18T03:10:49.135Z","updated_at":"2026-04-16T09:32:16.456Z","avatar_url":"https://github.com/atsyplenkov.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\",\n  dpi = 1000\n)\n\nrequireNamespace(\"smoothr\", quietly = TRUE)\nrequireNamespace(\"bench\", quietly = TRUE)\n```\n\n# filtrs\n\n\u003c!-- badges: start --\u003e\n[![R-CMD-check](https://github.com/atsyplenkov/filtrs/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/atsyplenkov/filtrs/actions/workflows/R-CMD-check.yaml)\n[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-maturing-blue.svg)](https://lifecycle.r-lib.org/articles/stages.html#maturing)\n[![CRAN status](https://www.r-pkg.org/badges/version/filtrs)](https://CRAN.R-project.org/package=filtrs)\n![GitHub R package version](https://img.shields.io/github/r-package/v/atsyplenkov/filtrs?label=github)\n![GitHub last commit](https://img.shields.io/github/last-commit/atsyplenkov/filtrs)\n\u003c!-- badges: end --\u003e\n\nRust-Boosted Linear and Spatial Filtering in R.\n\nCurrently, the package supports only the Whittaker-Eilers smoother as it is implemented in the `whittaker-eilers` [crate](https://crates.io/crates/whittaker-eilers). Based on that filter, a smoothing approach for spatial geometries (only single-part `LINESTRING` for now) is proposed.\n\n## Installation\n\nInstall from CRAN:\n\n``` r\ninstall.packages(\"filtrs\")\n```\n\nOr install the development version from GitHub:\n\n``` r\n# install.packages(\"remotes\")\nremotes::install_github(\"atsyplenkov/filtrs\")\n```\n\n## Time-series filtering\n\nFor equally-spaced data, one can use the `fil_wt` function as an API to `whittaker_eilers::WhittakerSmoother`. It has two controls, `lambda` and `order`, and interpolates missing values by default. An extremely nice description of the smoother is written by [Andrew Bowell](https://www.anbowell.com/blog/the-perfect-way-to-smooth-your-noisy-data).\n\n```{r timeseries}\nlibrary(filtrs)\n## basic example code\n\ndata(\"airquality\")\n\nairquality$Ozone_smooth \u003c- \n fil_wt(as.double(airquality$Ozone), 10, 2)\n\nplot(airquality$Ozone, type = \"l\", xlab = \"Days\", ylab = \"Ozone\")\nlines(airquality$Ozone_smooth, col = \"red\", lwd = 2)\n\n```\n\n## Spatial filtering\nSpatial data may not be equally spaced; it often has more nodes on the bends of lines and fewer on straight segments. To address this challenge, the distance between nodes—calculated using either Cartesian or Haversine methods, depending on the Coordinate Reference System (CRS)—is used as a positions vector in the background. The function `fil_wt_sf` is designed to smooth a single `LINESTRING`, proving particularly beneficial for processing high-frequency data, such as that obtained from satellite imagery.\n\n```{r spatial}\nlibrary(sf)\nlibrary(smoothr)\n\nfile_path \u003c- system.file(\"exdata/examples.gpkg\", package = \"filtrs\")\n\nlines \u003c- \n  sf::st_read(file_path, layer = \"gswe\", quiet = TRUE) |\u003e\n  # Increase nodes count for smoother result\n  smoothr::smooth(\"densify\", max_distance = 10)\n\nlines_wt \u003c- \n  fil_wt_sf(lines, lamda = 10^-7, order = 3)\n\nlines_smoothr \u003c-\n  smoothr::smooth(lines, method = \"ksmooth\",\n                  smoothness = 21)\n\n```\n\n\u003cdetails\u003e\n\u003csummary\u003ePlot’s code\u003c/summary\u003e\n```{r spatial_plot, eval=T, fig.show='hide'}\npar(\n  mar = c(0.5, 0.5, 0.2, 0.2),\n  mfrow = c(1, 2),\n  oma = c(0, 0, 0.2, 0.2)\n)\n\nplot(\n  sf::st_geometry(lines),\n  col = \"grey30\",\n  lwd = 3.5\n)\nplot(\n  sf::st_geometry(lines_wt),\n  col = 'firebrick3',\n  lwd = 2,\n  add = TRUE\n)\n\n# Add the legend\nlegend(\n  \"bottomleft\",\n  legend = c(\"Original\", \"{filtrs}\", \"{smoothr}\"),\n  col = c(\"grey30\", \"firebrick3\", \"dodgerblue3\"),\n  lwd = c(3, 3)\n)\n\nplot(\n  sf::st_geometry(lines),\n  col = \"grey30\",\n  lwd = 3.5\n)\nplot(\n  sf::st_geometry(lines_smoothr),\n  col = 'dodgerblue3',\n  lwd = 2,\n  add = TRUE\n)\n```\n\u003c/details\u003e\n\n\u003cimg src=\"man/figures/README-spatial_plot-1.png\" style=\"width:100.0%\" /\u003e\n\nSimilar filtering can be achieved via the [`smoothr`](https://github.com/mstrimas/smoothr) R package; however, the Rust-based approach outperforms in speed when high-order smoothing is needed. For example, `r nrow(sf::st_coordinates(lines))` nodes were filtered 30 times faster using the `filtrs` package rather than `smoothr`.\n\n```{r benchmark}\nbench::mark(\n  filtrs = fil_wt_sf(lines, lamda = 10^-7, order = 3),\n  smoothr = smoothr::smooth(lines, method = \"ksmooth\", smoothness = 21),\n  check = F,\n  relative = T\n)\n```\n\n## Similar packages\nAs linear and spatial filters are pretty common, there is no shortage of analogs.\n\n* **[smoothr](https://github.com/mstrimas/smoothr)** - Spatial feature smoothing written in base R. However, there is no Whittaker-Eilers smoother.\n\n* **[phenofit](https://github.com/eco-hydro/phenofit)** - As part of vegetation phenology, Whittaker-Eilers and Savitzky-Golay time-series filtering is implemented using Rcpp. No spatial filtering.\n\n* **[signal](https://cran.r-project.org/web/packages/signal/index.html)** - A set of signal processing functions originally written for 'Matlab' and 'Octave'. No spatial filtering.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatsyplenkov%2Ffiltrs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fatsyplenkov%2Ffiltrs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatsyplenkov%2Ffiltrs/lists"}