{"id":13857567,"url":"https://github.com/seasmith/sfx","last_synced_at":"2025-10-25T03:56:11.540Z","repository":{"id":43470828,"uuid":"247563889","full_name":"seasmith/sfx","owner":"seasmith","description":"Extra functions for 'sf' Simple Features in R","archived":false,"fork":false,"pushed_at":"2024-03-30T22:06:43.000Z","size":11895,"stargazers_count":12,"open_issues_count":5,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-08-06T03:04:08.129Z","etag":null,"topics":["r","r-spatial","spatial"],"latest_commit_sha":null,"homepage":"http://seasmith.github.io/packages/sfx/","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/seasmith.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}},"created_at":"2020-03-15T22:39:49.000Z","updated_at":"2024-01-19T04:07:39.000Z","dependencies_parsed_at":"2022-07-25T01:47:54.198Z","dependency_job_id":null,"html_url":"https://github.com/seasmith/sfx","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seasmith%2Fsfx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seasmith%2Fsfx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seasmith%2Fsfx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seasmith%2Fsfx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/seasmith","download_url":"https://codeload.github.com/seasmith/sfx/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225920406,"owners_count":17545482,"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-spatial","spatial"],"created_at":"2024-08-05T03:01:40.778Z","updated_at":"2025-10-25T03:56:06.505Z","avatar_url":"https://github.com/seasmith.png","language":"R","funding_links":[],"categories":["R"],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n# Extra 'sf' Simple Features manipulations\n\n[![CRAN](http://www.r-pkg.org/badges/version/sfx)](https://cran.r-project.org/package=sfx)\n[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-red.svg)](https://www.tidyverse.org/lifecycle/#experimental)\n[![License](http://img.shields.io/badge/license-GPL%20%28%3E=%202%29-brightgreen.svg?style=flat)](http://www.gnu.org/licenses/gpl-2.0.html)\n\nStill a work-in-progress -- I want to add a few more features, such as:\n  \n  * Random density points (random points with density values? why? guassian distribution for sampling?)\n  * Alternative density methods.\n  \n\nSee the [Reference section][ref_sec] for detailed examples.\n\n[ref_sec]: http://seasmith.github.io/packages/sfx/reference/index.html\n\n```{r, collapse=TRUE}\nlibrary(sf)\nlibrary(sfx)\nlibrary(ggplot2)\nlibrary(stars) # for geom_stars() \n\nolinda1 \u003c- sf::read_sf(system.file(\"shape/olinda1.shp\", package = \"sf\"))\n\nolinda1_centroids \u003c- olinda1  %\u003e%\n    sf::st_centroid()\n```\n\n## Point\n```{r}\n# MASS::kde2d kernel (default)\nolinda1_centroids %\u003e%\n    st_density() %\u003e%\n    ggplot() +\n    geom_sf(data = olinda1, fill = NA, color = \"gray80\") +\n    geom_sf(aes(color = density)) +\n    scale_color_viridis_c() +\n    theme_void()\n\n# KernSmooth::bkde2D kernel\nolinda1_centroids %\u003e%\n    st_density(method = \"bkde2D\") %\u003e%\n    ggplot() +\n    geom_sf(data = olinda1, fill = NA, color = \"gray80\") +\n    geom_sf(aes(color = density)) +\n    scale_color_viridis_c() +\n    theme_void()\n```\n\n## Grid\n```{r}\n# n = 10 produces a 10x10 grid\nolinda1_centroids %\u003e%\n    st_density(return_geometry = \"grid\", n = 10) %\u003e%\n    ggplot() +\n    geom_sf(data = olinda1, fill = NA, color = \"gray80\") +\n    geom_sf(aes(color = density)) +\n    scale_color_viridis_c() +\n    theme_void()\n```\n\n## Isoband\n```{r}\nolinda1_centroids %\u003e%\n    st_density(return_geometry = \"isoband\") %\u003e%\n    ggplot() +\n    geom_sf(aes(fill = level), alpha = 1) +\n    geom_sf(data = olinda1_centroids, color = \"red\", size = 2) +\n    scale_fill_viridis_c()\n```\n\n## Raster\n```{r, eval=TRUE}\n# NOT WORKING AS EXPECTED\nolinda1_centroids %\u003e%\n    st_density(return_geometry = \"raster\", n = 50) %\u003e%\n    # use lambda expr to place . inside geom_stars\n    # or else ggplot() will error on fortify() attempt\n    {\n      ggplot() +\n        geom_stars(data = .) +\n        coord_equal() +\n        theme_void() +\n        scale_fill_viridis_c() +\n        scale_x_discrete(expand = c(0, 0)) +\n        scale_y_discrete(expand = c(0, 0))\n    }\n```\n\n## Current Functions\n\n```{r, eval=FALSE}\n# Density estimation (kernel based)\nst_density\n\n# Joins\nst_inner_join\nst_left_join\nst_anti_join\nst_semi_join\n\n# Convert logical matrix to logical vector\nst_any\n\n# Binary logical helpers\nst_any_contains\nst_any_contains_properly\nst_any_covered_by\nst_any_covers\nst_any_crosses\nst_any_disjoint\nst_any_equals\nst_any_equals_exact\nst_any_intersects\nst_any_is_within_distance\nst_any_overlaps\nst_any_touches\nst_any_within\n\n# Unitless dimensions\nst_ul_area\nst_ul_distance\nst_ul_length\n\n# Bounding-box helpers\nst_extent\nst_xdist\nst_ydist\nst_xlim\nst_ylim\n```\n\n## Future Functions?\n\n```{r, eval=FALSE}\ngeom_sf_density()\nplot_sf_density()\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseasmith%2Fsfx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fseasmith%2Fsfx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseasmith%2Fsfx/lists"}