-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathREADME.Rmd
More file actions
56 lines (41 loc) · 2.09 KB
/
README.Rmd
File metadata and controls
56 lines (41 loc) · 2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
---
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).