https://github.com/jansim/rmaps
Easily render minimal maps for posters using R and ggplot.
https://github.com/jansim/rmaps
ggplot maps poster r
Last synced: 4 months ago
JSON representation
Easily render minimal maps for posters using R and ggplot.
- Host: GitHub
- URL: https://github.com/jansim/rmaps
- Owner: jansim
- Created: 2020-09-18T22:21:13.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2021-03-09T16:14:33.000Z (over 4 years ago)
- Last Synced: 2025-05-05T22:58:06.072Z (6 months ago)
- Topics: ggplot, maps, poster, r
- Language: R
- Homepage:
- Size: 6.22 MB
- Stars: 10
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.Rmd
Awesome Lists containing this project
README
---
output: github_document
---```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```# 🗺️ rmaps: Minimal maps generated with R and ggplot
[](./README_files/example.pdf)
Collection of R functions to render minimal maps using `ggplot`.
# Getting Started
This project is not a R package and thus cannot be installed. To use this project, clone the repository and run `renv::install()` to install necessary packages / dependencies (if you do not have `rev` installed yet, you might have to run `install.packages("renv")` first and restart your R session).
To quickly render a map, simply run the following snippet of code with the working directory set to this repository.```{r fig.height=7, fig.width=5, dpi=300, message=FALSE, warning=FALSE}
# This will load all included functions & packages
source("load.R")# Download mapdata
if (!file.exists(get_cache_path("amsterdam_example", type = "boundingbox"))) {
# Example bounding box of central Amsterdam
boundingbox <- st_bbox(c(xmin = 4.861836, ymin = 52.340088, xmax = 4.934535, ymax = 52.401469))
# This will download the data and automatically write it into a cache file
# so as to not overload the free OpenStreetMaps API. All the cached files
# can be found in data/cache in the directory of this repository.
download_mapdata(data_id = "amsterdam_example", boundingbox = boundingbox)
}# Load the data from cache
mapdata <- load_mapdata("amsterdam_example")# Render the final map (this function has options for recoloring etc.)
render_map(mapdata)
```## 🖨️ Print-ready PDFs
There is also a convenience function to render a full pdf ready for printing in DIN A1 size. If you want to create your own poster it might be a good start to just copy and adjust this function to your liking (or just use it as is!).
```{r message=FALSE, warning=FALSE}
# Generate pdf for printing
full_render_to_pdf(
mapdata,
name = "Amsterdam, Noord-Holland, Netherlands",
filename = "example.pdf",
dir = "README_files"
)
```The resulting PDF can be found [here](./README_files/example.pdf).