{"id":16472938,"url":"https://github.com/elipousson/maplayer","last_synced_at":"2025-03-21T06:32:15.639Z","repository":{"id":43509718,"uuid":"496240757","full_name":"elipousson/maplayer","owner":"elipousson","description":"✏️🟢 Make ggplot2 Map Layers","archived":false,"fork":false,"pushed_at":"2024-09-07T17:05:46.000Z","size":22740,"stargazers_count":9,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-17T22:14:43.036Z","etag":null,"topics":["ggplot2","r","r-package","rspatial","rstats"],"latest_commit_sha":null,"homepage":"https://elipousson.github.io/maplayer/","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"}},"created_at":"2022-05-25T13:22:53.000Z","updated_at":"2024-10-10T19:14:42.000Z","dependencies_parsed_at":"2024-06-19T08:34:07.517Z","dependency_job_id":null,"html_url":"https://github.com/elipousson/maplayer","commit_stats":{"total_commits":249,"total_committers":1,"mean_commits":249.0,"dds":0.0,"last_synced_commit":"bc0b9decd15107f7220234ab818b4747f49ff181"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elipousson%2Fmaplayer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elipousson%2Fmaplayer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elipousson%2Fmaplayer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elipousson%2Fmaplayer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elipousson","download_url":"https://codeload.github.com/elipousson/maplayer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244751632,"owners_count":20504243,"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":["ggplot2","r","r-package","rspatial","rstats"],"created_at":"2024-10-11T12:19:04.865Z","updated_at":"2025-03-21T06:32:15.181Z","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# maplayer \u003ca href=\"https://elipousson.github.io/maplayer/\"\u003e\u003cimg src=\"man/figures/logo.png\" align=\"right\" height=\"128\"/\u003e\u003c/a\u003e\n\n\u003c!-- badges: start --\u003e\n\n[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)\n[![Codecov test coverage](https://codecov.io/gh/elipousson/maplayer/branch/main/graph/badge.svg)](https://app.codecov.io/gh/elipousson/maplayer?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[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n\u003c!-- badges: end --\u003e\n\nThe goal of maplayer is to provide a consistent set of functions for creating map layers using simple feature ([{sf}](https://r-spatial.github.io/sf/)) data, the [{ggplot2}](https://ggplot2.tidyverse.org/) package, and a variety of ggplot2 extension packages.\n\n## Basic functions\n\nThe main layers that work with both a data and location sf object are:\n\n-   `layer_location_data()`\n-   `layer_location()`\n-   `layer_location_context()`\n\nThere are several layers that can work with a single sf object as the input data:\n\n-   `layer_markers()`\n-   `layer_numbers()`\n-   `layer_frame()`\n-   `layer_scaled()`\n-   `layer_mask()`\n-   `layer_neatline()`\n\nFinally, there are layers that require additional packages (listed in Suggests):\n\n-   `layer_labelled()` optionally uses [{ggrepel}](https://ggrepel.slowkow.com/) or [{geomtextpath}](https://allancameron.github.io/geomtextpath/)\n-   `layer_mapbox()` uses [{mapboxapi}](https://walker-data.com/mapboxapi/) (requires an API key)\n-   `layer_marked()` uses [{ggforce}](https://ggforce.data-imaginist.com/)\n-   `layer_icon()` uses [{ggsvg}](https://coolbutuseless.github.io/package/ggsvg/)\n-   `layer_inset()` uses [{patchwork}](https://patchwork.data-imaginist.com/) or optionally [{figpatch}](https://bradyajohnston.github.io/figpatch/) (for `stamp_inset_img()`)\n\nThe package also allows the optional use of packages designed for transforming spatial data or modifying ggplot2 maps. These include:\n\n-   [{smoothr}](https://strimas.com/smoothr/) (required to use the smooth_params argument)\n-   [{ggfx}](https://ggfx.data-imaginist.com/) (required to use the shadow_params argument)\n\nMany of the functions in {maplayer} were originally developed for the [{overedge}](chttps://elipousson.github.io/overedge/) package or before that for the [{mapbaltimore}](https://elipousson.github.io/mapbaltimore/) package. The {overedge} package has been split up into three smaller packages including {maplayer}, [{getdata}](https://elipousson.github.io/getdata/), and [{sfext}](https://elipousson.github.io/sfext/).\n\n## Installation\n\nYou can install the development version of maplayer like so:\n\n``` r\npak::pkg_install(\"elipousson/maplayer\")\n```\n\n## Example\n\n```{r setup}\nlibrary(maplayer)\nlibrary(ggplot2)\nlibrary(sf)\n```\n\n### Add icons to a map\n\n`layer_icon()` wraps `ggsvg::geom_point_svg()` to provide an convenient way to make icon maps.\n\nYou can create maps using a single named icon that matches one of the icons in `map_icons`.\n\n```{r}\nnc \u003c- read_sf(system.file(\"shape/nc.shp\", package = \"sf\"))\nnc \u003c- st_transform(nc, 3857)\ntheme_set(theme_void())\n\nnc_map \u003c-\n  ggplot() +\n  geom_sf(data = nc)\n\nnc_map +\n  layer_icon(data = nc, icon = \"point-start\", size = 8)\n```\n\n### Add a neatline to a map\n\n`layer_neatline()` hides major grid lines and axis label by default. The function is useful to draw a neatline around a map at a set aspect ratio.\n\n```{r}\nnc_map +\n  layer_neatline(\n    data = nc,\n    asp = \"6:4\",\n    color = \"gray60\", linewidth = 2, linetype = \"dashed\"\n  )\n```\n\n`layer_neatline()` can also be used to focus on a specific area of a map with the option to apply a buffer as a distance or ratio of the diagonal distance for the input data. The `label_axes` and `hide_grid` parameters will not override a set ggplot theme.\n\n```{r}\nnc_map +\n  layer_neatline(\n    data = nc[1, ],\n    diag_ratio = 0.5,\n    asp = 1,\n    color = \"black\",\n    label_axes = \"--EN\",\n    hide_grid = FALSE,\n    expand = FALSE\n  )\n```\n\n### Add labels or numbers to a map\n\n```{r}\nnc_map +\n  layer_labelled(\n    data = nc[c(10, 20, 30, 40), ],\n    geom = \"sf_label\",\n    mapping = aes(label = NAME)\n  )\n```\n\n```{r}\nnc_map +\n  layer_numbers(\n    data = nc[c(10, 20, 30, 40), ],\n    aes(fill = NAME),\n    num_style = \"Alph\",\n    size = 3.5\n  ) +\n  guides(fill = \"none\")\n```\n\n### Create a frame around a feature\n\n```{r}\ncircle_nc \u003c-\n  ggplot(data = nc) +\n  # layer_frame requires a data arg if neatline = TRUE\n  layer_frame(data = nc, style = \"circle\") +\n  # layer_location_data can inherit data\n  layer_location_data()\n\ncircle_nc\n```\n\n### Create an inset map\n\n```{r}\nnc_context \u003c-\n  layer_frame(\n    data = nc,\n    linetype = \"twodash\",\n    neatline = FALSE,\n    basemap = TRUE\n  ) +\n  layer_location_context(\n    location = nc[25, ],\n    context = nc,\n    context_params = list(fill = \"white\", color = \"gray80\", alpha = 1),\n    neatline = FALSE\n  )\n\nnc_context +\n  layer_neatline(\n    data = nc[25, ],\n    dist = 15,\n    unit = \"mi\",\n    asp = 1\n  ) +\n  layer_inset(\n    inset = nc_context,\n    scale = 1.5\n  )\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felipousson%2Fmaplayer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felipousson%2Fmaplayer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felipousson%2Fmaplayer/lists"}