{"id":33187078,"url":"https://oswaldosantos.github.io/ggsn/","last_synced_at":"2025-11-20T23:01:12.103Z","repository":{"id":36875863,"uuid":"41182842","full_name":"oswaldosantos/ggsn","owner":"oswaldosantos","description":"R package to add north symbols and scale bars to maps created with ggplot or ggmap","archived":false,"fork":false,"pushed_at":"2020-11-19T19:40:51.000Z","size":29390,"stargazers_count":161,"open_issues_count":11,"forks_count":8,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-09-08T13:56:01.631Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://oswaldosantos.github.io/ggsn/","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/oswaldosantos.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-08-22T00:06:49.000Z","updated_at":"2025-03-22T08:14:32.000Z","dependencies_parsed_at":"2022-08-21T05:50:57.474Z","dependency_job_id":null,"html_url":"https://github.com/oswaldosantos/ggsn","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/oswaldosantos/ggsn","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oswaldosantos%2Fggsn","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oswaldosantos%2Fggsn/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oswaldosantos%2Fggsn/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oswaldosantos%2Fggsn/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oswaldosantos","download_url":"https://codeload.github.com/oswaldosantos/ggsn/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oswaldosantos%2Fggsn/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":285526205,"owners_count":27186656,"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-11-20T02:00:05.334Z","response_time":54,"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":[],"created_at":"2025-11-16T05:00:30.371Z","updated_at":"2025-11-20T23:01:12.078Z","avatar_url":"https://github.com/oswaldosantos.png","language":"R","funding_links":[],"categories":["Spatial"],"sub_categories":[],"readme":"---\noutput:\n  md_document:\n    variant: markdown_github\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, echo = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"figure/\",\n  fig.width = 8,\n  fig.height = 10,\n  message = FALSE\n)\n```\n\nThe **ggsn** package improves the GIS capabilities of R, making possible to add 18 different north symbols and scale bars in kilometers, meters, nautical miles, or statue miles, to maps in geographic or metric coordinates created with **ggplot** or **ggmap**.\n\nTo install the CRAN version use: \n\n```R\ninstall.packages('ggsn')\n```\n\nTo install the development version use (make sure that **devtools** is installed):\n\n```R\ndevtools::install_github('oswaldosantos/ggsn')\n```\n\n## Examples\n\n```{r}\nlibrary(ggsn); library(ggplot2); library(sf)\ndata(\"domestic_violence\")\n```\n\n**ggplot** map:\n\n```{r}\n(ggm1 \u003c- ggplot(domestic_violence, aes(fill = Scaled)) +\n    geom_sf() +\n    scale_fill_continuous(low = \"#fff7ec\", high = \"#7F0000\"))\n```\n\nNow, let's use the **ggsn** package to add a blank background, a north symbol and a scale bar with segments of 5km:\n\n```{r}\nggm1 +\n    blank() +\n    north(domestic_violence) +\n    scalebar(domestic_violence, dist = 4, dist_unit = \"km\",\n             transform = TRUE, model = \"WGS84\")\n```\n\nThe scale bar works with maps in geographic and meter coordinates:\n\n```{r}\ndomestic_violence2 \u003c- st_transform(domestic_violence, 31983)\nggplot(domestic_violence2, aes(fill = Scaled)) +\n    geom_sf() +\n    scalebar(domestic_violence2, dist = 4, dist_unit = \"km\",\n             transform = FALSE, model = \"WGS84\") +\n    blank() +\n    scale_fill_continuous(low = \"#fff7ec\", high = \"#7F0000\")\n```\n\nWith facet plots, choose the variable and level variable to plot the scalebar.\n\n```{r}\n(fts \u003c- ggplot(domestic_violence, aes(fill = Scaled)) +\n  geom_sf(size = .1) +\n  facet_grid(Type ~ Value) +\n  scalebar(domestic_violence, dist = 8, dist_unit = \"km\", st.size = 3,\n           transform = TRUE, model = \"WGS84\",\n           facet.var = c(\"Type\", \"Value\"),\n           facet.lev = c(\"Humans\", \"Observed\")) +\n  theme_minimal() +\n  blank() +\n  scale_fill_continuous(low = \"#fff7ec\", high = \"#7F0000\"))\nnorth2(fts, .9)\n```\n\n\nThe packages **ggsn** and **ggmap** can be used together:\n```{r, warning=FALSE}\nlibrary(ggmap)\nsp \u003c- get_googlemap(\"São Paulo\", zoom = 9, scale = 2)\nggmap(sp) +\n    geom_sf(data = domestic_violence, aes(fill = Scaled),\n            inherit.aes = F) +\n    scalebar(x.min = -46.85, x.max = -46.38,\n                   y.min = -24, y.max = -23.35,\n                   dist = 4, dist_unit = \"km\",\n                   st.bottom = FALSE, st.color = \"red\",\n             transform = TRUE, model = \"WGS84\") +\n    blank() +\n    north(domestic_violence) +\n    scale_fill_continuous(low = \"#fff7ec\", high = \"#7F0000\") +\n    theme(legend.position = c(0.9, 0.35)) +\n    xlim(-46.85, -46.38) +\n    ylim(-24, -23.35)\n```\n\nTo see the available north symbols, use:\n\n```{r}\nnorthSymbols()\n```  \n\nFor more flexibility, read the functions' help pages.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/oswaldosantos.github.io%2Fggsn%2F","html_url":"https://awesome.ecosyste.ms/projects/oswaldosantos.github.io%2Fggsn%2F","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/oswaldosantos.github.io%2Fggsn%2F/lists"}