{"id":18722539,"url":"https://github.com/mdsumner/simpler","last_synced_at":"2026-04-02T01:17:07.357Z","repository":{"id":72211867,"uuid":"161416416","full_name":"mdsumner/simpler","owner":"mdsumner","description":null,"archived":false,"fork":false,"pushed_at":"2018-12-12T22:47:28.000Z","size":360,"stargazers_count":12,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-12T14:55:51.061Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mdsumner.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2018-12-12T01:36:02.000Z","updated_at":"2025-03-22T11:01:25.000Z","dependencies_parsed_at":"2023-03-11T12:00:06.989Z","dependency_job_id":null,"html_url":"https://github.com/mdsumner/simpler","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/mdsumner/simpler","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdsumner%2Fsimpler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdsumner%2Fsimpler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdsumner%2Fsimpler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdsumner%2Fsimpler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mdsumner","download_url":"https://codeload.github.com/mdsumner/simpler/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdsumner%2Fsimpler/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31293752,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-02T01:05:07.454Z","status":"ssl_error","status_checked_at":"2026-04-02T00:56:46.496Z","response_time":53,"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-07T13:41:54.581Z","updated_at":"2026-04-02T01:17:07.332Z","avatar_url":"https://github.com/mdsumner.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\noutput: github_document\neditor_options: \n  chunk_output_type: console\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r setup, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\"\n)\n```\n# simpler\n\nThe goal of simpler is to provide the [Visvalingam algorithm](https://bost.ocks.org/mike/simplify/) to \nsimplifying paths. \n\nVery much WIP!\n\nTODO: \n\n* distinguish shared boundaries from isolated lines, and drop short one\n* provide methods for various formats, especially polygons to shared boundaries\n* methods to recompose shared paths as polygons\n* \u003cdel\u003eavoid recalculating every triangle area every iteration\u003c/del\u003e fixed by vectorizing *removal*, rather than tricky in-place re-indexing \n\nNotes: \n\n- calculating triangle area is fast, the slowness comes from iterating over removals of focal points\n- how to avoid intersections that might occur (need examples)\n\n\n## Installation\n\nYou can install this **R** package with **remotes** using:\n\n```r\nremotes::install_github(\"mdsumner/simpler\")\n```\n\nIf you don't have the **remotes** package, that can be installed with:\n\n```r\ninstall.packages(\"remotes\")\n```\n\n\n## Example\n\nThe USA example, from Natural Earth. See https://bost.ocks.org/mike/simplify/ \n\n```{r usa}\nlibrary(simpler)\nw \u003c- rnaturalearth::ne_countries(scale = 10, country = \"United States of America\", returnclass = \"sf\")\nx \u003c- w$geometry[[1]][[1]][[1]]\n\n\nop \u003c- par(mfrow = c(3, 3), mar = rep(0, 4))\nplot(x, type = \"l\", axes = FALSE)\ntext(-100, 40, sprintf(\"vertices: %i\",  nrow(x)))\nfor (kpc in c(0.4, rep(0.6, 7))) {\n  x \u003c- simplify_path(x, keep_pc = kpc)\n  plot(x, type = \"l\", axes = FALSE)\n  text(-100, 40, sprintf(\"vertices: %i\",  nrow(x)))\n\n}\n\npar(op)\n\n```\n\nSimplify a bunch of shared lines (need better examples). \n\n\n```{r example}\nlibrary(sf)\nlibrary(silicate)\nget_pts \u003c- function(x, i) {\n  x$arc_link_vertex %\u003e% dplyr::filter(arc_ == x$object_link_arc$arc_[i]) %\u003e% \n    dplyr::inner_join(x$vertex, \"vertex_\") %\u003e% dplyr::select(x_, y_) %\u003e% as.matrix()\n}\nnc \u003c- read_sf(system.file(\"gpkg/nc.gpkg\", package = \"sf\"))\n\nnc1 \u003c- nc[c(1, 2, 3, 10, 19, 18, 23, 25, 22, 34, 41, 42, 32, 34, 41, 39, 50, 43, 46, 52), ]\nx \u003c- ARC(nc1)\nsfx \u003c- vector(\"list\", nrow(x$object_link_arc))\nop \u003c- par(mar = rep(0, 4))\n#plot(x$vertex$x_, x$vertex$y_, pch = \".\", asp = \"\")\nplot(nc1$geom, reset = FALSE)\nfor (i in seq_along(x$object_link_arc$arc_)) {\n  pts \u003c- get_pts(x, i)\n    path \u003c- simplify_path(pts, keep_pc = 0.1)\n  \n  lines(path, col = rainbow(10)[i %% 10 + 1], lwd = 2)\n  sfx[[i]] \u003c- sf::st_linestring(path)\n}\npar(op)\npoints(x$vertex$x_, x$vertex$y_, pch = 19, cex = 0.3)\n\n\n\n\nx \u003c- ARC(inlandwaters)\nplot(x)\nsfx \u003c- vector(\"list\", nrow(x$object_link_arc))\nplot(x$vertex$x_, x$vertex$y_, pch = \".\", asp = 1, xlim = c(4e5, 2e6), ylim = c(-1e6, 0))\nfor (i in seq_along(x$object_link_arc$arc_)) {\n pts \u003c- get_pts(x, i)\n path \u003c- simplify_path(pts, keep_pc = 0.001)\n lines(path, col = rainbow(10)[i %% 10 + 1], lwd = 3)\n sfx[[i]] \u003c- sf::st_linestring(path)\n}\n\n## this is a cheat because the polygons have to store any shared boundaries twice, \npryr::object_size(sf::st_sfc(sfx))\npryr::object_size(inlandwaters)\n\n\nplot(sf::st_sfc(sfx))\n```\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmdsumner%2Fsimpler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmdsumner%2Fsimpler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmdsumner%2Fsimpler/lists"}