{"id":16472935,"url":"https://github.com/elipousson/sfext","last_synced_at":"2026-03-16T01:44:34.144Z","repository":{"id":41500431,"uuid":"507698197","full_name":"elipousson/sfext","owner":"elipousson","description":"✂️🌐 A R package with extra options for simple features and spatial data","archived":false,"fork":false,"pushed_at":"2024-11-28T03:34:08.000Z","size":23361,"stargazers_count":19,"open_issues_count":2,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-10T16:54:14.708Z","etag":null,"topics":["r","r-package","rspatial","rstats","sf"],"latest_commit_sha":null,"homepage":"https://elipousson.github.io/sfext/","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/elipousson.png","metadata":{"files":{"readme":"README.Rmd","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":"codemeta.json","zenodo":null}},"created_at":"2022-06-26T22:28:46.000Z","updated_at":"2025-03-22T10:34:24.000Z","dependencies_parsed_at":"2024-01-12T05:27:17.817Z","dependency_job_id":"07a2aa85-80a3-4057-b258-9c6661330416","html_url":"https://github.com/elipousson/sfext","commit_stats":{"total_commits":570,"total_committers":1,"mean_commits":570.0,"dds":0.0,"last_synced_commit":"4cb4facf4ae0a4c30d993c3b8b0dd88df690b3d7"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/elipousson/sfext","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elipousson%2Fsfext","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elipousson%2Fsfext/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elipousson%2Fsfext/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elipousson%2Fsfext/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elipousson","download_url":"https://codeload.github.com/elipousson/sfext/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elipousson%2Fsfext/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265224162,"owners_count":23730346,"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":["r","r-package","rspatial","rstats","sf"],"created_at":"2024-10-11T12:19:03.841Z","updated_at":"2026-03-16T01:44:29.120Z","avatar_url":"https://github.com/elipousson.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)\n```\n\n# sfext \u003ca href=\"https://elipousson.github.io/sfext/\"\u003e\u003cimg src=\"man/figures/logo.png\" align=\"right\" height=\"118\" /\u003e\u003c/a\u003e\n\n\u003c!-- badges: start --\u003e\n[![CRAN status](https://www.r-pkg.org/badges/version/sfext)](https://CRAN.R-project.org/package=sfext)\n[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)\n [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![Codecov test coverage](https://codecov.io/gh/elipousson/sfext/branch/main/graph/badge.svg)](https://app.codecov.io/gh/elipousson/sfext?branch=main)\n[![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)\n\u003c!-- badges: end --\u003e\n\nThe goal of sfext is to extend existing functions from the [{sf} package](https://r-spatial.github.io/sf/) and offer a range of additional options for working with simple feature objects, bounding boxes, and data frame objects with coordinates or other spatial information.\n\n## Installation\n\nYou can install the development version of sfext like so:\n\n``` r\n# pak::pkg_install(\"elipousson/sfext\")\n```\n\n## Usage\n\n```{r setup}\nlibrary(sfext)\n```\n\n### Extending existing {sf} functions\n\n`{sfext}` is built around existing sf functions but designed to offer greater flexibility around both inputs and outputs. For example, `read_sf_ext()` is a wrapper for `sf::read_sf()` and offers a similar functionality:\n\n```{r}\nnc \u003c- read_sf_ext(system.file(\"shape/nc.shp\", package = \"sf\"))\n```\n\nHowever, `read_sf_ext()` also supports URLs for Google Sheets, FeatureLayers, data included with an installed package, and a variety of other sources. The function also supports an optional bounding box filter.\n\n\n```{r}\nread_sf_ext(\"https://carto.nationalmap.gov/arcgis/rest/services/govunits/MapServer/29\", bbox = as_bbox(nc))\n```\n\n`st_union_ext()` is nearly identical to `sf::st_union()` but optionally preserve a name column (collapsing the values of that column into a single string): \n\n```{r}\nrandom_id \u003c- sample(nrow(nc), size = 8)\n\nnc_union \u003c- st_union_ext(nc[random_id, ], name_col = \"NAME\")\n\nplot(\n  nc_union\n)\n```\n\n`st_buffer_ext()` wraps `sf::st_buffer()` but accepts bounding box objects as an input, allows you to set the units for the buffer distance using a character string (automatically converts the buffer distance units to match the units of the input object):\n\n```{r}\n# Apply a 20 mile buffer to the unioned geometry\nplot(\n  st_buffer_ext(nc_union, dist = 20, unit = \"mi\")\n)\n```\n\n`st_make_grid_ext()` wraps `sf::st_make_grid()` but makes it easy to set the dimensions of the grid using rows, columns, and an overall aspect ratio:\n\n```{r}\n# Make a 5 by 5 grid with a 8.5 by 11 aspect ratio filtered to x\nplot(\n  st_make_grid_ext(\n    x = nc,\n    asp = 11 / 8.5,\n    ncol = 5,\n    nrow = 5,\n    filter = TRUE\n  )\n)\n```\n\nMost functions that include a `crs` parameter can convert the coordinate reference system of the output (using `transform_sf()` or `sf_bbox_transform()`). The crs parameter also supports sf, sfc, or bbox inputs. Functions that include a `class` parameter can convert the class of an object using `as_sf_class()`. There are a set of functions for class conversion that typically wrap multiple sf functions with more limited input options.\n\n```{r}\nnc_bbox \u003c- as_bbox(nc, crs = 4326)\n\nnc_bbox\n\nas_sfc(nc[1, ], crs = 3857)\n\nas_sf(nc_bbox, crs = nc)\n```\nPlease note this flexibility make `{sfext}` easy to use (especially in an interactive context) but likely *not* appropriate for reproducible research. The package is being actively developed and the API may change.\n\n### Additional helper functions for `sf` objects\n\nsfext also includes several helper functions that add new features by combining functions from the {sf} package, using [affine geometry](https://r-spatial.github.io/sf/articles/sf3.html#affine-transformations), or adding features from other packages.\n\nFor example, `st_edge()` combines `sf::st_buffer()` and `sf::st_difference()` to get the \"edges\" of any geometry.\n\n```{r}\nplot(\n  st_edge(nc, dist = 10, unit = \"mi\"),\n  max.plot = 1\n)\n```\n\n`st_nudge()` allows you to shift the position of an `sf` object to a new location:\n\n```{r}\nnc_nudge \u003c- st_nudge(nc, to = nc[1, ])\n\nplot(\n  st_union_ext(\n    nc,\n    nc_nudge\n  ),\n  max.plot = 1\n)\n```\n\n`st_donut()` allows you to create donuts around existing features:\n\n```{r}\nplot(\n  st_donut(nc[c(1, 2, 3), ])\n)\n```\n\nLastly, the package has a whole group of helper functions for bbox objects. For example, `sf_bbox_corners()` creates a sf object with POINT geometry based on the corners of a bounding box:\n\n```{r}\nplot(\n  sf_bbox_corners(\n    as_bbox(nc)\n  )\n)\n```\n\n## Related projects\n\n`{sfext}` *depends* on two other development packages:\n\n- [{papersize}](https://elipousson.github.io/papersize/): A collection of convenience functions extending grid, ggplot2, and patchwork to help in sizing plots and files for printing to paper, postcards, playing cards, and other physical media.\n- [{filenamr}](https://elipousson.github.io/filenamr/): A package to help create and modify file names and paths (that also supports reading and writing EXIF metadata).\n\nIt is also *used* extensively by two other development packages:\n\n- [{getdata}](https://elipousson.github.io/getdata/): A package to make the experience of getting location data easier and more consistent across a wide variety of sources.\n- [{maplayer}](https://elipousson.github.io/maplayer/): A consistent set of functions for creating map layers for [{ggplot2}](https://ggplot2.tidyverse.org/) using simple feature data.\n\nThere are *many* packages that build on sf for a variety of specialized use cases. A few worth noting include:\n\n- [{sfdep}](https://github.com/JosiahParry/sfdep): A sf and tidyverse friendly interface to the spdep package for spatial dependence.\n- [{sfnetworks}](https://github.com/luukvdmeer/sfnetworks):  Tidy Geospatial Networks in R.\n- [{sfhotspot}](https://github.com/mpjashby/sfhotspot): A set of functions to identify and understand clusters of points (typically representing the locations of places or events).\n- [{sfx}](https://seasmith.github.io/packages/sfx/): Extra ‘sf’ Simple Features manipulations.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felipousson%2Fsfext","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felipousson%2Fsfext","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felipousson%2Fsfext/lists"}