{"id":13423625,"url":"https://github.com/r-spatial/s2","last_synced_at":"2025-03-15T17:32:01.783Z","repository":{"id":37012605,"uuid":"257671440","full_name":"r-spatial/s2","owner":"r-spatial","description":"Spherical Geometry Operators Using the S2 Geometry Library","archived":false,"fork":false,"pushed_at":"2025-02-22T15:18:06.000Z","size":13613,"stargazers_count":74,"open_issues_count":18,"forks_count":11,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-03-10T00:55:02.231Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://r-spatial.github.io/s2/","language":"C++","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/r-spatial.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","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":"2020-04-21T17:48:53.000Z","updated_at":"2025-01-23T05:12:35.000Z","dependencies_parsed_at":"2023-12-19T17:30:35.789Z","dependency_job_id":"77054ab1-7705-49ae-99f9-7aa9b2656bfb","html_url":"https://github.com/r-spatial/s2","commit_stats":{"total_commits":831,"total_committers":12,"mean_commits":69.25,"dds":0.2033694344163658,"last_synced_commit":"29c11b4b3ff97314c9d5d224f6a4437f327f5d36"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r-spatial%2Fs2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r-spatial%2Fs2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r-spatial%2Fs2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r-spatial%2Fs2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/r-spatial","download_url":"https://codeload.github.com/r-spatial/s2/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243767034,"owners_count":20344858,"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","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-07-31T00:00:39.153Z","updated_at":"2025-03-15T17:32:01.749Z","avatar_url":"https://github.com/r-spatial.png","language":"C++","funding_links":[],"categories":["C++"],"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)\n```\n\n# s2\n\n\u003c!-- badges: start --\u003e\n[![R-CMD-check](https://github.com/r-spatial/s2/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/r-spatial/s2/actions/workflows/R-CMD-check.yaml)\n[![codecov](https://codecov.io/gh/r-spatial/s2/branch/main/graph/badge.svg)](https://app.codecov.io/gh/r-spatial/s2)\n[![CRAN](http://www.r-pkg.org/badges/version/s2)](https://cran.r-project.org/package=s2)\n[![Downloads](http://cranlogs.r-pkg.org/badges/s2?color=brightgreen)](https://www.r-pkg.org/pkg/s2)\n\u003c!-- badges: end --\u003e\n\nThe s2 R package provides bindings to Google's [S2Geometry](http://s2geometry.io) library. The package exposes an API similar to Google's [BigQuery Geography API](https://cloud.google.com/bigquery/docs/reference/standard-sql/geography_functions), whose functions also operate on spherical geometries. Package [sf](https://cran.r-project.org/package=sf) uses this package by default for nearly all its geometrical operations on objects with ellipsoidal (unprojected) coordinates; in cases where it doesn't, such as `st_relate()`, it emits a warning.\n\nThis package is a complete rewrite of an earlier CRAN package s2 with versions up\nto 0.4-2, for which the sources are found [here](https://github.com/spatstat/s2/).\n\n## Installation\n\nYou can install the released version of s2 from [CRAN](https://CRAN.R-project.org) with:\n\n``` r\ninstall.packages(\"s2\")\n```\n\nAnd the development version from [GitHub](https://github.com/) with:\n\n``` r\n# install.packages(\"remotes\")\nremotes::install_github(\"r-spatial/s2\")\n```\n\nThe S2 package requires [Abseil]() and OpenSSL. You can install these using a system package manager on most platforms:\n\n- Windows: Both OpenSSL and Abseil are available from RTools since R 4.3\n- MacOS: `brew install openssl abseil`\n- Debian/Ubuntu: `apt-get install libssl-dev libabsl-dev`\n- Fedora: `dnf install openssl-devel abseil-cpp-devel`\n- Alpine: `apk add abseil-cpp`\n\n## Example\n\nThe s2 package provides geometry transformers and predicates similar to those found in [GEOS](https://trac.osgeo.org/geos/), except instead of assuming a planar geometry, s2's functions work in latitude and longitude and assume a spherical geometry:\n\n```{r example}\nlibrary(s2)\n\ns2_contains(\n  # polygon containing much  of the northern hemisphere\n  \"POLYGON ((-63.5 44.6, -149.75 61.20, 116.4 40.2, 13.5 52.51, -63.5 44.6))\",\n  # ...should contain the north pole\n  \"POINT (0 90)\"\n)\n```\n\nThe [sf package](https://r-spatial.github.io/sf/) uses s2 for geographic coordinates with `sf::sf_use_s2(TRUE)`, and will become the default after sf version 1.0.0. The sf package also supports creating s2 vectors using `as_s2_geography()`:\n\n```{r, warning=FALSE, message = FALSE}\nlibrary(dplyr)\nlibrary(sf)\n\nnc_s2 \u003c- read_sf(system.file(\"shape/nc.shp\", package = \"sf\")) %\u003e%\n  mutate(geometry = as_s2_geography(geometry)) %\u003e%\n  as_tibble() %\u003e%\n  select(NAME, geometry)\n\nnc_s2\n```\n\nUse accessors to extract information about geometries:\n\n```{r}\nnc_s2 %\u003e%\n  mutate(\n    area = s2_area(geometry),\n    perimeter = s2_perimeter(geometry)\n  )\n```\n\nUse predicates to subset vectors:\n\n```{r}\nnc_s2 %\u003e%\n  filter(s2_contains(geometry, \"POINT (-80.9313 35.6196)\"))\n```\n\nUse transformers to create new geometries:\n\n```{r}\nnc_s2 %\u003e%\n  mutate(geometry = s2_boundary(geometry))\n```\n\nFinally, use the WKB or WKT exporters to export to sf or some other package:\n\n```{r}\nnc_s2 %\u003e%\n  mutate(geometry = st_as_sfc(s2_as_binary(geometry))) %\u003e%\n  st_as_sf()\n```\n\n## Acknowledgment\n\nThis project gratefully acknowledges financial [support](https://r-consortium.org/) from the\n\n\u003ca href=\"https://r-consortium.org/\"\u003e\n\u003cimg src=\"man/figures/rc300.png\" width=\"300\" /\u003e\n\u003c/a\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fr-spatial%2Fs2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fr-spatial%2Fs2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fr-spatial%2Fs2/lists"}