{"id":13654050,"url":"https://github.com/dkahle/ggmap","last_synced_at":"2025-10-21T20:54:13.796Z","repository":{"id":1946942,"uuid":"2876618","full_name":"dkahle/ggmap","owner":"dkahle","description":"A package for plotting maps in R with ggplot2","archived":false,"fork":false,"pushed_at":"2025-08-31T21:12:20.000Z","size":138181,"stargazers_count":777,"open_issues_count":143,"forks_count":237,"subscribers_count":46,"default_branch":"master","last_synced_at":"2025-10-15T06:10:39.179Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/dkahle.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS","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,"zenodo":null}},"created_at":"2011-11-29T17:14:54.000Z","updated_at":"2025-10-06T09:13:22.000Z","dependencies_parsed_at":"2023-07-06T01:52:33.176Z","dependency_job_id":"97f93e4c-6f45-449d-935a-01465cb8cf53","html_url":"https://github.com/dkahle/ggmap","commit_stats":{"total_commits":380,"total_committers":15,"mean_commits":"25.333333333333332","dds":"0.24736842105263157","last_synced_commit":"2cc32a47cf2730f592680f7d698942aaca32382c"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/dkahle/ggmap","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dkahle%2Fggmap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dkahle%2Fggmap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dkahle%2Fggmap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dkahle%2Fggmap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dkahle","download_url":"https://codeload.github.com/dkahle/ggmap/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dkahle%2Fggmap/sbom","scorecard":{"id":346535,"data":{"date":"2025-08-11","repo":{"name":"github.com/dkahle/ggmap","commit":"29ed82523e46332aa77364717bd042f8ee314337"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.6,"checks":[{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Code-Review","score":0,"reason":"Found 2/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"License","score":0,"reason":"license file not detected","details":["Warn: project does not have a license file"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 2 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-18T07:10:54.027Z","repository_id":1946942,"created_at":"2025-08-18T07:10:54.027Z","updated_at":"2025-08-18T07:10:54.027Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280333496,"owners_count":26312845,"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-10-21T02:00:06.614Z","response_time":58,"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":"2024-08-02T02:01:22.563Z","updated_at":"2025-10-21T20:54:13.791Z","avatar_url":"https://github.com/dkahle.png","language":"R","funding_links":[],"categories":["R","R Packages","パッケージ紹介","Spatial","Table of Contents","Spatial Visualization"],"sub_categories":["Spatial Analysis","ggmap","Visualization","Miscellaneous"],"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 setup, echo = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE, cache = FALSE,\n  comment = \"# \",\n  fig.path = \"tools/README-\",\n  dpi = 60 # 60 on CRAN; 300 on github\n)\n```\n\n\u003c!-- badges: start --\u003e\n[![CRAN status](https://www.r-pkg.org/badges/version/ggmap)](https://cran.r-project.org/package=ggmap)\n[![AppVeyor build status](https://ci.appveyor.com/api/projects/status/github/dkahle/ggmap?branch=master\u0026svg=true)](https://ci.appveyor.com/project/dkahle/ggmap)\n\u003c!-- badges: end --\u003e\n\n\n\n\u003chr\u003e\n\n# ggmap\n\n__ggmap__ is an R package that makes it easy to retrieve raster map tiles from\npopular online mapping services like [Google\nMaps](https://developers.google.com/maps/documentation/maps-static?hl=en),\n[Stadia Maps](https://stadiamaps.com/), and\n[OpenStreetMap](https://www.openstreetmap.org/), and plot them using the\n[__ggplot2__](https://github.com/tidyverse/ggplot2) framework.\n\n## Stadia Maps\n\nStadia Maps offers map tiles in several styles, including updated [tiles from\nStamen Design](https://stadiamaps.com/stamen/). An API key is required, but no\ncredit card is necessary to [sign up](https://client.stadiamaps.com/signup) and\nthere is a free tier for non-commercial use. Once you have your API key, invoke\nthe registration function: `register_stadiamaps(\"YOUR-API-KEY\", write =\nFALSE)`{.R}. Note that setting `write = TRUE`{.R} will update your `~/.Renviron`\nfile by replacing/adding the relevant line. If you use the former, know that\nyou'll need to re-do it every time you reset R.\n  \nYour API key is _private_ and unique to you, so be careful not to share it\nonline, for example in a GitHub issue or saving it in a shared R script file. If\nyou share it inadvertently, just go to client.stadiamaps.com, delete your API\nkey, and create a new one.\n\n```{r maptypes, fig.height=4, fig.width=7}\nlibrary(\"ggmap\")\n\nus \u003c- c(left = -125, bottom = 25.75, right = -67, top = 49)\nget_stadiamap(us, zoom = 5, maptype = \"alidade_smooth\") |\u003e ggmap() \n```\n\nUse `qmplot()`{.R} in the same way you'd use `qplot()`{.R}, but with a map\nautomatically added in the background:\n\n```{r qmplot, fig.height=5, fig.width=5}\nlibrary(\"dplyr\", warn.conflicts = FALSE)\nlibrary(\"forcats\")\n\n# define helper\n`%notin%` \u003c- function(lhs, rhs) !(lhs %in% rhs)\n\n# reduce crime to violent crimes in downtown houston\nviolent_crimes \u003c- crime |\u003e \n  filter(\n    offense %notin% c(\"auto theft\", \"theft\", \"burglary\"),\n    between(lon, -95.39681, -95.34188),\n    between(lat, 29.73631, 29.78400)\n  ) |\u003e \n  mutate(\n    offense = fct_drop(offense),\n    offense = fct_relevel(offense, c(\"robbery\", \"aggravated assault\", \"rape\", \"murder\"))\n  )\n\n# use qmplot to make a scatterplot on a map\nqmplot(lon, lat, data = violent_crimes, maptype = \"stamen_toner_lite\", color = I(\"red\"))\n```\n\nOften `qmplot()`{.R} is easiest because it automatically computes a nice\nbounding box for you without having to pre-compute it for yourself, get a map,\nand then use `ggmap(map)`{.R} in place of where you would ordinarily (in a\n**ggplot2** formulation) use `ggplot()`{.R}. Nevertheless, doing it yourself is\nmore efficient. In that workflow you get the map first (and you can visualize it\nwith `ggmap()`{.R}):\n\n```{r ggmap, fig.height=5, fig.width=5}\nbbox \u003c- make_bbox(lon, lat, data = violent_crimes)\nmap \u003c- get_stadiamap( bbox = bbox, maptype = \"stamen_toner_lite\", zoom = 14 )\nggmap(map)\n```\n\nAnd then you layer on geoms/stats as you would with **ggplot2**. The only difference is that (1) you need to specify the `data` arguments in the layers and (2) the spatial aesthetics `x` and `y` are set to `lon` and `lat`, respectively. (If they're named something different in your dataset, just put `mapping = aes(x = longitude, y = latitude))`, for example.)\n\n```{r ggmap-layers, fig.height=5, fig.width=5}\nggmap(map) +\n  geom_point(data = violent_crimes, color = \"red\")\n```\n\n\nWith **ggmap** you're working with **ggplot2**, so you can add in other kinds of layers, use [**patchwork**](https://patchwork.data-imaginist.com), etc.\nAll the __ggplot2__ geom's are available.  For example, you can make a contour\nplot with `geom = \"density2d\"`{.R}:\n\n```{r ggmap-patchwork, warning=FALSE, fig.height=4, fig.width=8}\nlibrary(\"patchwork\")\nlibrary(\"ggdensity\")\n\nrobberies \u003c- violent_crimes |\u003e filter(offense == \"robbery\")\n\npoints_map \u003c- ggmap(map) + geom_point(data = robberies, color = \"red\")\n\n# warnings disabled\nhdr_map \u003c- ggmap(map) + \n  geom_hdr(\n    aes(lon, lat, fill = after_stat(probs)), data = robberies,\n    alpha = .5\n  ) +\n  geomtextpath::geom_labeldensity2d(\n    aes(lon, lat, level = after_stat(probs)),\n    data = robberies, stat = \"hdr_lines\", size = 3, boxcolour = NA\n  ) +\n  scale_fill_brewer(palette = \"YlOrRd\") +\n  theme(legend.position = \"none\")\n\n(points_map + hdr_map) \u0026 \n  theme(axis.title = element_blank(), axis.text = element_blank(), axis.ticks = element_blank())\n```\n\nFaceting works, too:\n\n```{r faceting, fig.height=2.5, fig.width=8}\nggmap(map, darken = .3) +\n  geom_point(\n    aes(lon, lat), data = violent_crimes, \n    shape = 21, color = \"gray25\", fill = \"yellow\"\n  ) +\n  facet_wrap(~ offense, nrow = 1) +\n  theme(axis.title = element_blank(), axis.text = element_blank(), axis.ticks = element_blank())\n```\n\n\n\n\n\n## Google Maps\n\n[Google Maps](https://cloud.google.com/maps-platform/terms) can be used just as\neasily.  However, since Google Maps use a center/zoom specification, their input\nis a bit different:\n```{r google_maps, fig.height=5, fig.width=5}\n(map \u003c- get_googlemap(\"waco texas\", zoom = 12))\nggmap(map)\n```\n\nMoreover, you can get various different styles of Google Maps with __ggmap__\n(just like Stadia Maps):\n```{r google_styles, eval=FALSE}\nget_googlemap(\"waco texas\", zoom = 12, maptype = \"satellite\") |\u003e ggmap()\nget_googlemap(\"waco texas\", zoom = 12, maptype = \"hybrid\") |\u003e ggmap()\nget_googlemap(\"waco texas\", zoom = 12, maptype = \"roadmap\") |\u003e ggmap()\n```\n\nGoogle's geocoding and reverse geocoding API's are available through `geocode()`{.R}\nand `revgeocode()`{.R}, respectively:\n```{r geocode}\ngeocode(\"1301 S University Parks Dr, Waco, TX 76798\")\nrevgeocode(c(lon = -97.1161, lat = 31.55098))\n```\n\n_Note: `geocode()` uses Google's Geocoding API to geocode addresses. Please take care not to disclose sensitive information. Rundle, Bader, and Moody (2022) (`https://pmc.ncbi.nlm.nih.gov/articles/PMC8972108/`) have considered this issue and suggest various alternative options for such data._\n\nThere is also a `mutate_geocode()`{.R} that works similarly to\n[__dplyr__](https://github.com/tidyverse/dplyr/)'s `mutate()`{.R} function:\n```{r mutate_geocode}\ntibble(address = c(\"white house\", \"\", \"waco texas\")) |\u003e \n  mutate_geocode(address)\n```\n\nTreks use Google's routing API to give you routes (`route()`{.R} and\n`trek()`{.R} give slightly different results; the latter hugs roads):\n```{r route_trek, fig.height=5, fig.width=5}\ntrek_df \u003c- trek(\"houson, texas\", \"waco, texas\", structure = \"route\")\nqmap(\"college station, texas\", zoom = 8) +\n  geom_path(\n    aes(x = lon, y = lat),  colour = \"blue\",\n    size = 1.5, alpha = .5,\n    data = trek_df, lineend = \"round\"\n  )\n```\n\n(They also provide information on how long it takes to get from point A to point\nB.)\n\n\nMap distances, in both length and anticipated time, can be computed with\n`mapdist()`{.R}).  Moreover the function is vectorized:\n```{r mapdist}\nmapdist(c(\"houston, texas\", \"dallas\"), \"waco, texas\")\n```\n\n\n\n## Google Maps API key\n\nA few years ago Google has [changed its API\nrequirements](https://developers.google.com/maps/documentation/geocoding/usage-and-billing),\nand __ggmap__ users are now required to register with Google. From a user's\nperspective, there are essentially three ramifications of this:\n\n1. Users must register with Google. You can do this at\nhttps://mapsplatform.google.com. While it will require a valid credit card\n(sorry!), there seems to be a fair bit of free use before you incur charges, and\neven then the charges are modest for light use.\n\n2. Users must enable the APIs they intend to use. What may appear to __ggmap__\nusers as one overarching \"Google Maps\" product, Google in fact has several\nservices that it provides as geo-related solutions. For example, the [Maps\nStatic\nAPI](https://developers.google.com/maps/documentation/maps-static/overview)\nprovides map images, while the [Geocoding\nAPI](https://developers.google.com/maps/documentation/geocoding/overview)\nprovides geocoding and reverse geocoding services.  Apart from the relevant\nTerms of Service, generally __ggmap__ users don't need to think about the\ndifferent services. For example, you just need to remember that\n`get_googlemap()`{.R} gets maps, `geocode()`{.R} geocodes (with Google, DSK is\ndone), etc., and __ggmap__ handles the queries for you.  _However_, you do need\nto enable the APIs before you use them. You'll only need to do that once, and\nthen they'll be ready for you to use. Enabling the APIs just means clicking a\nfew radio buttons on the Google Maps Platform web interface listed above, so\nit's easy.\n\n3. Inside R, after loading the new version of __ggmap__, you'll need provide\n__ggmap__ with your API key, a [hash\nvalue](https://en.wikipedia.org/wiki/Hash_function) (think string of jibberish)\nthat authenticates you to Google's servers. This can be done on a temporary\nbasis with `register_google(key = \"[your key]\")`{.R} or permanently using\n`register_google(key = \"[your key]\", write = TRUE)`{.R} (note: this will\noverwrite your `~/.Renviron` file by replacing/adding the relevant line). If you\nuse the former, know that you'll need to re-do it every time you reset R.\n  \nYour API key is _private_ and unique to you, so be careful not to share it\nonline, for example in a GitHub issue or saving it in a shared R script file. If\nyou share it inadvertantly, just get on Google's website and regenerate your key\n- this will retire the old one. Keeping your key private is made a bit easier by\n__ggmap__ scrubbing the key out of queries by default, so when URLs are shown in\nyour console, they'll look something like `key=xxx`{.R}.  (Read the details\nsection of the `register_google()`{.R} documentation for a bit more info on this\npoint.)\n\nThe new version of __ggmap__ is now on CRAN soon, but you can install the latest\nversion, including an important bug fix in `mapdist()`{.R}, here with:\n```{r attn, eval=FALSE}\nif(!requireNamespace(\"devtools\")) install.packages(\"devtools\")\ndevtools::install_github(\"dkahle/ggmap\")\n```\n\n\n\n\n## Installation\n\n* From CRAN: `install.packages(\"ggmap\")`{.R}\n\n* From Github: \n```{r, eval=FALSE}\nif (!requireNamespace(\"remotes\")) install.packages(\"remotes\")\nremotes::install_github(\"dkahle/ggmap\")\n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdkahle%2Fggmap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdkahle%2Fggmap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdkahle%2Fggmap/lists"}