{"id":24895421,"url":"https://github.com/symbolixau/googlepolylines","last_synced_at":"2025-10-16T10:31:01.192Z","repository":{"id":85449994,"uuid":"112591684","full_name":"SymbolixAU/googlePolylines","owner":"SymbolixAU","description":"R package for encoding objects using Google's Polyline Encoding Algorithm","archived":false,"fork":false,"pushed_at":"2025-07-26T04:26:38.000Z","size":36158,"stargazers_count":21,"open_issues_count":19,"forks_count":7,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-09-29T06:43:00.556Z","etag":null,"topics":["geospatial","gis","google-maps","polyline-encoder","r","r-spatial","rstats","spatial"],"latest_commit_sha":null,"homepage":"","language":"C++","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/SymbolixAU.png","metadata":{"files":{"readme":"README.md","changelog":"NEWS.md","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,"zenodo":null}},"created_at":"2017-11-30T09:24:10.000Z","updated_at":"2025-07-26T04:26:51.000Z","dependencies_parsed_at":"2025-09-29T23:48:42.513Z","dependency_job_id":null,"html_url":"https://github.com/SymbolixAU/googlePolylines","commit_stats":{"total_commits":258,"total_committers":7,"mean_commits":"36.857142857142854","dds":"0.16279069767441856","last_synced_commit":"beb5347ca3b4f0afc4462eeddccaea8f2c47891d"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/SymbolixAU/googlePolylines","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SymbolixAU%2FgooglePolylines","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SymbolixAU%2FgooglePolylines/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SymbolixAU%2FgooglePolylines/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SymbolixAU%2FgooglePolylines/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SymbolixAU","download_url":"https://codeload.github.com/SymbolixAU/googlePolylines/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SymbolixAU%2FgooglePolylines/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279178941,"owners_count":26120322,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-16T02:00:06.019Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["geospatial","gis","google-maps","polyline-encoder","r","r-spatial","rstats","spatial"],"created_at":"2025-02-01T19:18:30.184Z","updated_at":"2025-10-16T10:30:59.511Z","avatar_url":"https://github.com/SymbolixAU.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n[![R build status](https://github.com/SymbolixAU/googlePolylines/workflows/R-CMD-check/badge.svg)](https://github.com/SymbolixAU/googlePolylines/actions)\n[![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/googlePolylines)](https://CRAN.R-project.org/package=googlePolylines)\n[![Codecov test coverage](https://codecov.io/gh/SymbolixAU/googlePolylines/branch/master/graph/badge.svg)](https://app.codecov.io/gh/SymbolixAU/googlePolylines?branch=master)\n![downloads](http://cranlogs.r-pkg.org/badges/grand-total/googlePolylines)\n\n\n# googlePolylines\n\nA **fast** and light-weight implementation of [Google's polyline encoding algorithm](https://developers.google.com/maps/documentation/utilities/polylinealgorithm). \n\n\n\u003e Polyline encoding is a lossy compression algorithm that allows you to store a series of coordinates as a single string. \n\n\n## Installation\n\nFrom CRAN\n\n```r\ninstall.packages(\"googlePolylines\")\n```\n\nFrom github (dev version)\n\n```r\nremotes::install_github(\"SymbolixAU/googlePolylines\")\n```\n\n## Scope\n\nBecause `googlePolylines` uses Google's polyline encoding algorithm, all functions assume Google Web Mercator projection (WSG 84 / EPSG:3857 / EPSG:900913) for inputs and outputs. Objects that use other projections should be re-projected into EPSG:3857 before using these functions.\n\n`googlePolylines` supports Simple Feature objects (from `library(sf)`), `data.frame`s, and vectors of lon/lat coordinates.\n\nSupported `sf` types \n\n- POINT\n- MULTIPOINT\n- LINESTRING\n- MULTILINESTRING\n- POLYGON\n- MULTIPOLYGON\n- GEOMETRY\n\n## Examples\n\n`googlePolylines` contains functions to encode coordinates into polylines, and also to parse polylines to and from well-known text format.\n\n### `encode`\n\n```r\nlibrary(googlePolylines)\nlibrary(sf)\n\n# create data\n\ndf \u003c- data.frame(myId = c(1,1,1,1,1,1,1,1,2,2,2,2),\n\t\t\t\tlineId = c(1,1,1,1,2,2,2,2,1,1,1,2),\n\t\t\t\tlon = c(-80.190, -66.118, -64.757, -80.190,  -70.579, -67.514, -66.668, -70.579, -70, -49, -51, -70),\n\t\t\t\tlat = c(26.774, 18.466, 32.321, 26.774, 28.745, 29.570, 27.339, 28.745, 22, 23, 22, 22))\n\np1 \u003c- as.matrix(df[1:4, c(\"lon\", \"lat\")])\np2 \u003c- as.matrix(df[5:8, c(\"lon\", \"lat\")])\np3 \u003c- as.matrix(df[9:12, c(\"lon\", \"lat\")])\n\n# create `sf` collections\n\npoint \u003c- sf::st_sfc(sf::st_point(x = c(df[1,\"lon\"], df[1,\"lat\"])))\nmultipoint \u003c- sf::st_sfc(sf::st_multipoint(x = as.matrix(df[1:2, c(\"lon\", \"lat\")])))\npolygon \u003c- sf::st_sfc(sf::st_polygon(x = list(p1, p2)))\nlinestring \u003c- sf::st_sfc(sf::st_linestring(p3))\nmultilinestring \u003c- sf::st_sfc(sf::st_multilinestring(list(p1, p2)))\nmultipolygon \u003c- sf::st_sfc(sf::st_multipolygon(x = list(list(p1, p2), list(p3))))\n\n# combine all types into one collection\n\nsf \u003c- rbind(\n\tsf::st_sf(geo = polygon),\n\tsf::st_sf(geo = multilinestring),\n\tsf::st_sf(geo = linestring),\n\tsf::st_sf(geo = point),\n\tsf::st_sf(geo = multipoint)\n\t)\n\nsf\n\n# Simple feature collection with 5 features and 0 fields\n# geometry type:  GEOMETRY\n# dimension:      XY\n# bbox:           xmin: -80.19 ymin: 18.466 xmax: -49 ymax: 32.321\n# epsg (SRID):    NA\n# proj4string:    NA\n#                              geo\n# 1 POLYGON ((-80.19 26.774, -6...\n# 2 MULTILINESTRING ((-80.19 26...\n# 3 LINESTRING (-70 22, -49 23,...\n# 4          POINT (-80.19 26.774)\n# 5 MULTIPOINT (-80.19 26.774, ...\n\n# encode sf objects\n\nencode(sf)\n\n                                       geo\n# 1         POLYGON: ohlbDnbmhN~suq@am{tA...\n# 2 MULTILINESTRING: ohlbDnbmhN~suq@am{tA...\n# 3      LINESTRING: _{geC~zfjL_ibE_qd_C~...\n# 4                     POINT: ohlbDnbmhN...\n# 5                MULTIPOINT: ohlbDnbmhN...\n\n\n# encode data frame as a list of points\n\nencode(df)\n# [1] \"ohlbDnbmhN~suq@am{tAw`qsAeyhGvkz`@fge}Aw}_Kycty@gc`DesuQvvrLofdDorqGtzzVfkdh@uapB_ibE_qd_C~hbE~reK?~|}rB\"\n\n\n```\n\n### Polyline to well-known text\n\n```r\n\nenc \u003c- encode(sf)\nwkt \u003c- polyline_wkt(enc)\nwkt\n                                                                                                                                       geo\n# 1 POLYGON ((-80.19 26.774, -66.1...\n# 2 MULTILINESTRING ((-80.19 26.77...\n# 3 LINESTRING (-70 22, -49 23, -5...\n# 4          POINT (-80.19 26.774)...\n# 5 MULTIPOINT ((-80.19 26.774),(-...\n```\n\n### Well-known text to polyline\n\n```r\nenc2 \u003c- wkt_polyline(wkt)\n```\n\n\n## Motivation\n\nEncoding coordinates into polylines reduces the size of objects and can increase the speed in plotting Google Maps and Mapdeck\n\n\n```r\nlibrary(sf)\nlibrary(geojsonsf)\nsf \u003c- geojsonsf::geojson_sf(\"https://raw.githubusercontent.com/SymbolixAU/data/master/geojson/SA1_2016_VIC.json\")\n\nencoded \u003c- encode(sf, FALSE)\nencodedLite \u003c- encode(sf, TRUE)\n\nvapply(mget(c('sf', 'encoded', 'encodedLite') ), function(x) { format(object.size(x), units = \"Kb\") }, '')\n#           sf      encoded  encodedLite \n# \"38750.7 Kb\" \"14707.9 Kb\"  \"9649.8 Kb\"\n```\n\n```r\nlibrary(microbenchmark)\nlibrary(sf)\nlibrary(geojsonsf)\nlibrary(leaflet)\nlibrary(googleway)\nlibrary(mapdeck)\n\nsf \u003c- geojsonsf::geojson_sf(\"https://raw.githubusercontent.com/SymbolixAU/data/master/geojson/SA1_2016_VIC.json\")\n\nmicrobenchmark(\n\n  google = {\n\n    ## you need a Google Map API key to use this function\n    google_map(key = mapKey) %\u003e%\n      add_polygons(data = sf)\n  },\n  \n  mapdeck = {\n    mapdeck(token = mapKey) %\u003e%\n      add_polygon(data = sf)\n  },\n\n  leaflet = {\n    leaflet(sf) %\u003e%\n      addTiles() %\u003e%\n      addPolygons()\n  },\n  times = 25\n)\n\n# Unit: milliseconds\n#     expr       min        lq      mean    median        uq       max neval\n#   google  530.4193  578.3035  644.9472  606.3328  726.4577  897.9064    25\n#  mapdeck  527.7255  577.2322  628.5800  600.7449  682.2697  792.8950    25\n#  leaflet 3247.3318 3445.6265 3554.7433 3521.6720 3654.1177 4109.6708    25\n \n```\nThese benchmarks don't account for the time taken for the browswer to render the maps\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsymbolixau%2Fgooglepolylines","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsymbolixau%2Fgooglepolylines","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsymbolixau%2Fgooglepolylines/lists"}